BeginningWebDesign
asked on
System.Web.HttpRequestValidationException
Hello EE Community
Does anyone know how to redirect a site visitor to another page if the System.Web.HttpRequestVali dationExce ption detects an invalid form entry.
I have tried the following but recieve an error:
void Page_Init()
{
if(System.Web.HttpRequestV alidationE xception == true)
Response.Redirect("index.a spx");
}
Compiler Error Message: CS0118: 'System.Web.HttpRequestVal idationExc eption' denotes a 'class' where a 'variable' was expected
Source Error:
Line 44: void Page_Init()
Line 45: {
Line 46: if(System.Web.HttpRequestV alidationE xception == true)
Line 47: Response.Redirect("index.a spx");
Line 48: }
Source File: C:\*** Line: 46
Thank you in advance
Caz
Does anyone know how to redirect a site visitor to another page if the System.Web.HttpRequestVali
I have tried the following but recieve an error:
void Page_Init()
{
if(System.Web.HttpRequestV
Response.Redirect("index.a
}
Compiler Error Message: CS0118: 'System.Web.HttpRequestVal
Source Error:
Line 44: void Page_Init()
Line 45: {
Line 46: if(System.Web.HttpRequestV
Line 47: Response.Redirect("index.a
Line 48: }
Source File: C:\*** Line: 46
Thank you in advance
Caz
Hello,
An exception is automatically thrown by the system if one exception occurs. The HttpRequestValidationExcep tion exception that is thrown when a potentially dangerous input string is received from the client.
You can use try-catch block to catch the exception and redirect users according to your need.
Tri
An exception is automatically thrown by the system if one exception occurs. The HttpRequestValidationExcep
You can use try-catch block to catch the exception and redirect users according to your need.
Tri
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the reply everyone
As I'm new to EE, can you tell me what I need to do about the answers supplied by ihenry and msreekm as both relate to the same subject.
I tried tovvenki code but that did not work.
The other option to this question would be how can I validate a form on the server side when it is being posted to another page.
The two text boxes are strUsername and strPassword and the regular expression I'm using to validate them are: "^[^<>`~!/ \#}$%:;)(_^{&*=|'+]+$"
Caz
As I'm new to EE, can you tell me what I need to do about the answers supplied by ihenry and msreekm as both relate to the same subject.
I tried tovvenki code but that did not work.
The other option to this question would be how can I validate a form on the server side when it is being posted to another page.
The two text boxes are strUsername and strPassword and the regular expression I'm using to validate them are: "^[^<>`~!/ \#}$%:;)(_^{&*=|'+]+$"
Caz
use the try ..catch block like
try
{
//your code here
}catch(System.Web.HttpRequ
{
Response.Redirect("index.a
}
regards,
venki