We discovered problem when deploying MVC application on IIS7 server: any route navigation gives 404 error. I've found on web that problem can be solved by setting application pool managed pipeline mode to integrated, but now we have exception:
Request is not available in this context
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Request is not available in this context
Source Error:
Line 19:
Line 20: public override void SetActiveUser(Guid userOid) {
Line 21: FormsAuthentication.SignOut();
Line 22: HttpContext.Current.Items[Key] = userOid.ToString();
Line 23: FormsAuthentication.RedirectFromLoginPage(userOid.ToString(), true);
Does anybody have any ideas?
The problem is probably in the web.config file. Since IIS7 there is now two places to configure handlers and modules. When you run in classic mode, is like running on IIS 6 (though under IIS7).
Here is the config file:
<system.web>
[...]
<httpHandlers>
[...]
</httpHandlers>
<httpModules>
[...]
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
there should be only IIS 6 configurations.
IIS 7 config should be placed under:
<system.webServer>
[...]
<modules runAllManagedModulesForAllRequests="true" >
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
To glom onto what kvalcanti stated. The standard routing was designed for IIS 7. There is a kludge added for older versions of IIS. So, if you are deving on older versions, you have the kludged up version of the config file. Changing the config solves the issue.
In addition to what kvalcanti mentions, there is a possibility you have a bit of a kludge set up in your global.asax, as well. I am not sure it is still mandatory in the newest version of ASP.NET MVC, or not, as I have not deved on anything but Vista in the last few months.
This post has some insight: http://www.developingfor.net/aspnet-mvc/deploying-aspnet-mvc-on-iis6.html
Scott Guthrie had a great blog post about this on his blog (http://weblogs.asp.net/scottgu/), but I don't have it bookmarked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With