Naveen Billure
Naveen Billure

Reputation: 59

Redirecting from one page of .aspx to another .aspx page using C#

i am using two .aspx pages in my application. Second page implements a dropdownlist which is binded with the database using collection. now i want to redirect from second page to my first page. i used

Response.Redirect("~/Admin/Home.aspx");

but its throwing an exception which follows like this

System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (ctl00$MainContent$DropDownList1="").

I want to resolve this exception. Any new ideas regarding this problem are expected.

Thanks in advance

Upvotes: 0

Views: 1979

Answers (3)

Full Time Skeleton
Full Time Skeleton

Reputation: 1740

There's some text in your dropdown that ASP.NET considers dangerous. Either change it (it's probably some possibly dangerous character like '; etc.)

Or, at the top of the page in the page declaration add 'EnableEventValidation=false'

There are security concerns with turning this off though so best read up on it first.

Upvotes: 2

Adrian Wragg
Adrian Wragg

Reputation: 7401

I suspect you've misidentified the location of where your error is being thrown. It's not in the redirection itself, it's in the PostBack that calls it.

The actual answer to your problem can be found at A potentially dangerous Request.Form value was detected from the client (textboxError="<Responses><Response..."); you will need the validateRequest that the other answers mention, but you also need to set requestValidationMode="2.0" in web.config.

Upvotes: 3

Murugavel
Murugavel

Reputation: 279

set

validateRequest="false"

I hope this will help you.

Upvotes: 1

Related Questions