Difference between II6 and IIS7 using ASP.NET forms post action?

Apr 4, 2009 at 12:27 PM
Hi,

I wonder what's going wrong in my migration from using IIS 6 to 7;

In IIS6 my ASP.NET produced a URL http://www.prijsvaneenhuis.nl/Prijs-Van-Huizen-In-De-Postcode/1093ED/13/Overzicht.aspx, which has its FORM action attribute set RELATIVELY to the root of the website;

<form name="aspnetForm" method="post" action="../../../ZoekWoning/PostcodeDetail.aspx?p=1093ED&amp;n=13" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" AUTOCOMPLETE="off">

In IIS7 when I generate the same page, the form action URL looks like so:

        <form name="aspnetForm" method="post" action="PostcodeDetail.aspx?p=1093ED&amp;n=13" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" AUTOCOMPLETE="off">

The result is that in IIS7 is a "file does not exist", handled in my global.asax.

The file '/Prijs-Van-Huizen-In-De-Postcode/1093ED/13/PostcodeDetail.aspx' does not exist. 
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

My rule line looks like so (for both IIS 6 and IIS 7):

RewriteRule /Prijs-Van-Huizen-In-De-Postcode/(.*)/(.*)/Overzicht.aspx /ZoekWoning/PostcodeDetail.aspx?p=$1&n=$2 [NE]

Is this some misconfiguration I did in my web.config? 
Any thoughts would be highly appreciated,

Regards,
Gert-Jan 
http://NFileStorage.CodePlex.com
Coordinator
Apr 4, 2009 at 3:32 PM
Hi Gert-Jan,

Make sure you follow the ReadMe.txt for IIS 7 to the letter if you haven't:

http://urlrewriter.codeplex.com/SourceControl/changeset/view/27780#364373

Secondly, set the following in the <rules /> tag:

rewriteFormPostBack="false"
rebaseClientPath="true"
allowIis7TransferRequest="true"

let me know if this helps or any new errors come up.

Nick
Apr 4, 2009 at 4:21 PM
Hi there Nick,

Thanks for your quick reply and suggestion, unfortunately it didn't solve the error I get.

Just for the record; in the URL to which you referred (http://urlrewriter.codeplex.com/SourceControl/changeset/view/27780#364373) it says (no matter IIS 6 or 7) ;
<rules fileName="ManagedFusion.Rewriter.rules" rebaseClientPath="false" rewriteFormPostBack="true" />
where-as, as you suggest;
<rules rebaseClientPath="true"  rewriteFormPostBack="false" allowIis7TransferRequest="true" />

So far I used the rules as defined in the text document (which didn't work out for me), so I ofcourse tried what you suggested; see below:

[SCENARIO A] (using <rules rebaseClientPath="true"  rewriteFormPostBack="false" allowIis7TransferRequest="true" /> and the SEO-ed URL)

T = 1; I browse to http://localhost:82/Prijs-Van-Huizen-In-De-Postcode/1093ED/13/Overzicht.aspx, so this is a GET request, output [O1] shows up OK in the browser, so the Url rewriting piece works ok there. The form in [O1] looks like this:

        <form name="aspnetForm" method="post" action="PostcodeDetail.aspx?p=1093ED&amp;n=13" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" AUTOCOMPLETE="off">

T = 2; I POST the form of [O1], result is an Application_Error event being caught in the Global.asax;

        protected void Application_Error(object sender, EventArgs e)
        {
            if (Response.StatusCode == 200)
            {
                //get reference to the source of the exception chain
                Exception ex = Server.GetLastError().GetBaseException();

The Exception message:

ex = {"The file '/Prijs-Van-Huizen-In-De-Postcode/1093ED/13/PostcodeDetail.aspx' does not exist."}

The stacktrace:

"   at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)\r\n   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)\r\n   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)\r\n   at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)\r\n   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)\r\n   at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)\r\n   at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)"

[SCENARIO B]

When I do not use the URL rewritten URL, but the traditional ugle looking URL the post does work:

T = 1; I browse to http://localhost:82//ZoekWoning/PostcodeDetail.aspx?p=1093ED&n=13, so this is a GET request, output is [O1]. The form on [O1] one looks like so:

      <form name="aspnetForm" method="post" action="PostcodeDetail.aspx?p=1093ED&amp;n=13" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" AUTOCOMPLETE="off">

T = 2; I POST the form of [O1] it works OK (no Exception is thrown). 

-------------

In my first post on this forum I thought the issue was related to the "..\.." relative url difference, but on second thought that's not the issue, since if I now compare the output between scenario A and B, it appears the FORM's actions attributes are identical;

From [O1] in Scenario A;        <form name="aspnetForm" method="post" action="PostcodeDetail.aspx?p=1093ED&amp;n=13" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" AUTOCOMPLETE="off">
From [O1] in Scenario B;        <form name="aspnetForm" method="post" action="PostcodeDetail.aspx?p=1093ED&amp;n=13" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" AUTOCOMPLETE="off">

-------------

I also tried scenario C, where i used the config <rules rebaseClientPath="false"  rewriteFormPostBack="true" allowIis7TransferRequest="true" / but the result was the same; an exception being thrown

Hopefully you have some suggestions left :)

Thanks in advance,
Gert-Jan
Coordinator
Apr 4, 2009 at 4:39 PM
Gert-Jan,

Those are just generic options that work over all, like everything else in software development, don't take them as gospel.  Also make sure while using IIS 7 that your Application Pool is set to "Integrated". 

Thanks,
Nick
Apr 5, 2009 at 10:12 AM
Hi Nick,

App pool was already set to 'Integrated', so no luck there. I will try to increase the logging level from 0 to some higher level to see if I can detect something over there...

Regards,
Gert-Jan