简体   繁体   English

使用C#从.aspx的页面重定向到另一个.aspx页面

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

i am using two .aspx pages in my application. 我在应用程序中使用两个.aspx页面。 Second page implements a dropdownlist which is binded with the database using collection. 第二页实现了一个下拉列表,该下拉列表使用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=""). System.Web.HttpRequestValidationException:从客户端检测到潜在危险的Request.Form值(ctl00 $ MainContent $ DropDownList1 =“”)。

I want to resolve this exception. 我想解决此异常。 Any new ideas regarding this problem are expected. 有关此问题的任何新想法都可以期待。

Thanks in advance 提前致谢

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. 它不在重定向本身中,而是在PostBack中调用它。

The actual answer to your problem can be found at A potentially dangerous Request.Form value was detected from the client (textboxError="<Responses><Response...") ; 您的问题的实际答案可以在A潜在危险的Request.Form值从客户端检测到(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. 您将需要其他答案提到的validateRequest ,但还需要在web.config中设置requestValidationMode="2.0"

There's some text in your dropdown that ASP.NET considers dangerous. 下拉菜单中有一些文本被ASP.NET认为很危险。 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' 或者,在页面声明的页面顶部添加“ EnableEventValidation = false”

There are security concerns with turning this off though so best read up on it first. 尽管最好先阅读一下,但关闭它仍存在安全隐患。

set

validateRequest="false" validateRequest =“ false”

I hope this will help you. 我希望这能帮到您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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