I really want and need to unvalidate a request with UrlData[0], is this possible? I do not want to use Request.Unvalidated(querystring) because there's no querystring.
For Example (scrape.cshtml):
http://www.example.com/scrape/result: <my name is>
string sInput = UrlData[0]; // this needs to be unvalidated
sInPut should be "result: <my name is>" // urlDecoded
I've installed Web Matrix 2.0 Beta & Webpages 2.0 as part of MVC 4.0 with Visual Web Developer Express SP1
I know about xss/sql injection, I do escape everything.. back & forth, up & down :-)
EDIT: Actually: there should be an option to disable the whole validation routine completely.
You can't use Request.Unvalidated on UrlData, but you can turn off Request.Path validation by adding the following to the system.web section of your web.config file:
JeepNL
Member
53 Points
22 Posts
Unvalidate UrlData[0] - Is this Possible? (Like Request.Unvalidated)
Feb 26, 2012 05:40 PM|LINK
I really want and need to unvalidate a request with UrlData[0], is this possible? I do not want to use Request.Unvalidated(querystring) because there's no querystring.
For Example (scrape.cshtml):
http://www.example.com/scrape/result: <my name is>
string sInput = UrlData[0]; // this needs to be unvalidated
sInPut should be "result: <my name is>" // urlDecoded
I've installed Web Matrix 2.0 Beta & Webpages 2.0 as part of MVC 4.0 with Visual Web Developer Express SP1
I know about xss/sql injection, I do escape everything.. back & forth, up & down :-)
EDIT: Actually: there should be an option to disable the whole validation routine completely.
Mikesdotnett...
All-Star
154818 Points
19853 Posts
Moderator
MVP
Re: Unvalidate UrlData[0] - Is this Possible? (Like Request.Unvalidated)
Feb 26, 2012 06:16 PM|LINK
You can't use Request.Unvalidated on UrlData, but you can turn off Request.Path validation by adding the following to the system.web section of your web.config file:
Edit: if you want to disable request validaiton across the whole site, add this too:
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
JeepNL
Member
53 Points
22 Posts
Re: Unvalidate UrlData[0] - Is this Possible? (Like Request.Unvalidated)
Feb 26, 2012 07:15 PM|LINK
Thank you for your answer Mike, but I think this doesn't work with this URL, SEO friendly, routing. Now I get the error:
"Server Error in '/' Application.
Illegal characters in path."
(Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272)
My web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" />
<compilation targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" validateRequest="false" />
<customErrors mode="Off"/>
</system.web>
<appSettings>
<add key="webPages:Version" value="2.0"/>
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
** EDIT **
contents of scrape.cshtml
@{
string sInput = "";
if (!UrlData[0].IsEmpty())
{
sInput = UrlData[0];
}
}
<!DOCTYPE html>
<html>
<head>
<title>Scrape</title>
</head>
<body>
<p>@sInput</p>
</body>
</html>