Link to home
Create AccountLog in
Avatar of taz8020
taz8020Flag for United Kingdom of Great Britain and Northern Ireland

asked on

I get System.Web.HttpRequestValidationException

Hi to make sure uses dont get error i have added code to email me if an error occurs and i keep getting a System.Web.HttpRequestValidationException but when I test all seems fine.
Please help me fix it.

this is the email i get:
-------------------------------------------------------

URL:      /default.aspx
User:      
Exception Type:      System.Web.HttpRequestValidationException
Message:      A potentially dangerous Request.Form value was detected from the client (ctl00$LogInHeader1$QuickSearch1$TextBoxQuickSearch="...oh/dp/vl,
Stack Trace:      at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
at System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection)
at System.Web.HttpRequest.get_Form()
at System.Web.HttpRequest.get_Item(String key)
at Telerik.Web.UI.RadCompression.IsAjaxRequest()
at Telerik.Web.UI.RadCompression.Compress(HttpApplication application)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

>(ctl00$LogInHeader1$QuickSearch1$TextBoxQuickSearch="...oh/dp/vl,

Are you using the page yourself when the error comes up? What do you put in the textbox? Its complaining about values in that textbox which may appear to be html, script etc.
Avatar of taz8020

ASKER

Hi, no it not when i am testing it but get the same message about 20-30 times a day.
What i dont understand, is when the search button is pressed i remove all non allowed characters. so it should then read oh+dp+vl
>when the search button is pressed i remove all non allowed characters.

Using Javascript?
Avatar of taz8020

ASKER

No on the asp.net clickevent, why should i do it via java?
Because the error is raised when textbox content is received by asp.net and it contains html at that point.
Avatar of taz8020

ASKER

So how would you do it in JavaScript? I take it you would do it on the on click event by will that fire before the vb function runs. Please help
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of taz8020

ASKER

Hi I need to do it more like this, but not working any ideas?

<script type="text/javascript">
    function RemoveNonAllowedChar(sender) {
        var newValue = sender.value.replace(/[^a-zA-Z0-9]/g, '+');
        sender.value = newValue;
    }
</script>
Are you calling this function in button's OnClientClick? If you try the code in the link, does that work?
Avatar of taz8020

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for taz8020's comment #a39309859

for the following reason:

Thanks did it on the blur event