【发布时间】:2011-04-20 18:41:43
【问题描述】:
我的 global.asax 中有这个
void Application_BeginRequest(object sender, EventArgs e)
{
string pathAndQuery = Request.Url.PathAndQuery.ToString().ToLower();
if (pathAndQuery.Contains("prettyUrl"))
{
HttpContext.Current.RewritePath("Category.aspx?catg=uglyUrl");
}
}
它工作正常,但我有时会得到这个 500 无法验证数据 所以我想这是因为校验和是代表 url 生成的。与视图状态不匹配。
那么你如何解决它,以便你可以使用RewritePath 但不会收到 500 错误?
编辑忘了提到我在 web.config 中有一个静态机器密钥验证密钥
Edit2发现其他人也有同样的问题:http://bytes.com/topic/asp-net/answers/298680-form-action-context-rewritepath#post1172026
当有回发时,重写路径会导致无效的视图状态
【问题讨论】:
-
您有什么想问的吗?
标签: asp.net c#-4.0 url-rewriting viewstate