I’m heavily using the new ASP.NET URL Routing feature introduced in .NET Framework 3.5 SP1 in my new ASP.NET Applications instead of traditional URL Rewriting. I actually wanted to use IIS7 URL Rewriting, but there’s no way to test your rewrite rules if you are using the built-in VS2008 Cassini Webserver for development (yet).
So I’ve set up some sweet URL Routing rules with Webforms and I have to say it works pretty good so far. However, sooner or later I stumbled upon the first problem. I used an UpdatePanel on a webform which went through the URL Routing mechanism. As soon as I hit the postback button I got the following error:
Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the quest on the server. The status code returned from the server was: 404.
Obviously because the form action attribute didn’t supply the full URL and that is the problem. You can fix it by adding this to your Page_Load:
form1.Action = HttpContext.Current.Request.RawUrl;
I just added it into the MasterPage Page_Load as I’m using URL Routing all over the Page. That’ll fix it.
I’ve also seen this:
if (!String.IsNullOrEmpty(Request.ServerVariables["HTTP_X_ORIGINAL_URL"]))
{
form1.Action = Request.ServerVariables["HTTP_X_ORIGINAL_URL"];
}
However, that snippet doesn’t work for me, I actually don’t know why. If that’s the case for you, too, just use the RawURL snippet above (without an if block).
1 comment so far ↓
Thanks. It works for me
Leave a Comment