When postback, it will cause a 301 redirect to get the rewrite page, so it will lose the original post.
http://blogs.iis.net/ruslany/archive/2008/10/23/asp-net-postbacks-and-url-rewriting.aspx
The key solution:
protected void Page_Load(object sender, EventArgs e)
{
if ( !String .IsNullOrEmpty(Request.ServerVariables["HTTP_X_ORIGINAL_URL" ]) )
{
form1.Action = Request.ServerVariables["HTTP_X_ORIGINAL_URL" ];
}
}
本文介绍了一个ASP.NET中常见的问题:当进行Postback操作时遇到301重定向导致原始POST数据丢失的情况。通过设置`HTTP_X_ORIGINAL_URL`变量到表单的Action属性来保留原始请求,解决了此问题。
192

被折叠的 条评论
为什么被折叠?



