简体   繁体   中英

Text within Special Characters break asp.net page

The problem is i have several controls on a page.... Listboxes/dropdowns/textboxes. And some of these controls do autopostbacks inside an update panel.

If a user enters < > and inside those brackets, any text, into a text control, and they happen to fire the autopostback by doing something else on the page (this autopostback has to fire for certain controls to work as intended) it will cause a scriptResource error

0x800a139e - JavaScript runtime error: 
Sys.WebForms.PageRequestManagerServerErrorException: A potentially dangerous Request.Form 
value was detected from the client 

I know this is working as intended since asp.net has protection from injection built in, but I was wondering if there was anyway to work around this, without turning of the validation from the link below, and by keeping the user from using the special characters on keypress events.

I have searched for an answer to this and the only one I have found was this link -- http://bytes.com/topic/asp-net/answers/339955-special-characters-textbox

Use validateRequest = "false" on page directive or in web.config

<system.web><httpRuntime requestValidationMode="2.0" /></system.web>

Check out this for applications ASP.Net 4 or later: http://msdn.microsoft.com/en-us/library/hh882339(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM