What are possible reasons for "Potentially dangerous Request.RawUrl"?
In an asp.net web forms application we get an error message with "A potentially dangerous Reques开发者_开发知识库t.RawUrl" sometimes, but I cannot find the source of it.
What are the possible reasons for this exception?
Some details from our case:
Event message: A validation error has occurred Exception type: System.Web.HttpRequestValidationException Exception message: A potentially dangerous Request.RawUrl value was detected from the client (="..._Combin%20%20%20%20%20%2..."). Request URL: https://somesite/somepage.aspx ?_TSM_HiddenField_=ctl00_sm1_HiddenField &_TSM_Combin%20</div>%20%20%20%20%20%20%20%20<div%20id= Stack trace: at System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) at System.Web.HttpRequest.get_RawUrl() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.somepage_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I recognise the part with TSM_HiddenField in the html of the generated page:
<script src="/somepage.aspx?_TSM_HiddenField_=ctl00_sm1_HiddenField&_TSM_CombinedScripts_= %3b%3bAjaxControlToolkit%2c+Version%3d3.5.11119.20050%2c+Culture%3dneutral%2c +PublicKeyToken%3d28f01b0e84b6d53e%3ada-DK%3a8e147239-dd05-47b0-8fb3-f743a139f982 %3ae2e86ef9%3a1df13a87%3a8ccd9c1b%3ac4c00916%3a9ea3f0e2%3a9e8e87e9 %3a4c9865be%3aba594826%3ac76f1358" type="text/javascript"></script>
... so it seems to be related to AjaxControlToolkit in this case, but how can this exception happen?
(It happens when a user is logged in, so I doubt there is some crawler or hack attempt involved...)
Looks like you have HTML markups in the submitted form fields, could be this one:
&_TSM_Combin%20</div>%20%20%20%20%20%20%20%20<div%20id=
The <div>
's the culprit.
I think it has to do with ASP.NET request validation: http://www.asp.net/learn/whitepapers/request-validation/
It throws the exception if e. g. HTML tags are sent with the request.
精彩评论