ASP.NET 4.5 MVC 4 not working on Windows Server 2008 IIS 7

Clearly I’m missing something, I’m unable to deploy a simple ASP.NET MVC 4, .NET 4.5 app on a Windows Small Business Server 2008 on IIS 7.

.NET framework 4.5 is installed.

Should I be supposed to see that version (4.5) on the Application Pool basic settings of the application? At this time, I only have 2.0 and 4.0, since 4.5 is like the 3.5 which only add on top of the 4.0 framework, I guess this is normal.

When I browse the home page, I got the following error:

403 – Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.

When I request the only controller named Page /page/index I get the 404 not found page. Like the ASP.NET process never get the http request.

I can request a simple HTML page.

The Application Pool is set to .NET 4.0 and Integrated as the Managed pipeline mode.

NETWORK SERVICE has read/write access to the directory.

The app work flawlessly from VS2012 of course.

I’m clueless on what’s not right here, and search engine queries are not helping much.

Does anyone would have a hint, that would be extremely appreciated.
Thanks

Edit

The dlls are already on the bin folder like System.Web.Mvc, System.Web.Razor etc.

I created a empty test.aspx page to make sure asp.net worker process was getting the request, and yes the page was OK. So it appears that the MVC routing is not working, though I have ASP.NET MVC 3 web app working fine on that server.

After the .NET 4.5 installation I did a aspnet_regiis -iru in case, that added an aspnet_client folder on the app, but still this does not fix the issue.

Anonymous Authentication is Enable on IIS Authentication section, and Authorization show allow for all users.

ASP.NET MVC 4 is installed, I just did a repair to make sure.

Eventhough the ASP.NET MVC 4 is installed, the 404 error from requesting the /page/index action is returned by the standard IIS and not the standard aspnet error. So indeed it appears like the MVC 4 framework is not properly installed, by I just double check and do a repair. Where can I continue to investigate?

@Mystere Man, I’ve changed the Anonymous Authentication to use the Application Pool identity, stop, start the app and still the same error. It really look like if ASP.NET MVC 4 is not taking the request.

Here is a part of the web.config:

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="*" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="*" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>

Edit 2012/09/27

I’ve re-pair Microsoft Framework .NET 4.5 and repair the ASP.NET MVC 4, re-deploy the simple ASP.NET MVC 4 app, and I still get the same behaviour. I’m not sure what to do next, so I started a bounty in the hope that someone could help me find the problem.

Edit 2014/01/31

When I asked that question, I flagged the runAllManagedModulesForAllRequests as the accepted answer because it did solve the problem. But I was certainly not going to use this in production. I ask why I had to do this and did not have any answers.

Than Martin Hollingsworth answer was really what I was looking for, a good way to fix this problem without all the performance issues related to the runAllManagedModulesForAllRequests.

We almost gave up and bought a new Windows 2012 server (from which the ASP.NET MVC app work as is). After trying Martin’s solution, the Windows 2008 server worked.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try using this:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    ...
</system.webServer>

EDIT:

The solution above will work for .NET 3.5 or below.
If you are using .NET 4.0 or above, you might want to try installing IIS7 QFE

Also, this article is worth reading to understand the difference between those two.

Method 2

If you are not able to apply the QFE from kb 980368, instead of using the runAllManagedModulesForAllRequests solution as suggested in the accepted answer, you should use the modules configuration with preCondition=”” shown below to avoid the negative impact on static content as described in the blog posts How asp.NET MVC Routing Works and its Impact on the Performance of Static Requests and Don’t use runAllManagedModulesForAllRequests=”true” when getting your MVC routing to work and some of the comments on the answers.

Scott Hanselman’s blog post about runAllManagedModulesForAllRequests should add some weight to this argument. Rick Strahl’s post Caveats with the runAllManagedModulesForAllRequests in IIS 7/8 is the best explanation of the interaction between the settings I have found. The IIS documentation on the module preCondition attribute is also worth a read.

Remember this configuration change is not necessary if you have applied the QFE as this behaviour becomes the default.

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>

Method 3

I had a similar problem. I tried many of the solutions described here (the Web.Config system.webServer configuration entry, etc) to no avail. At the very end, I discovered what the issue was with my particular installation. I was publishing my website to the local file system and then copying those files onto the server. It turned out that the file Global.asax was not being part of the published files. Once I copied that file, the error went away.

Method 4

As per https://stackoverflow.com/a/12521807/695829

I had the same issue and this hotfix fixed it: : http://support.microsoft.com/kb/980368

Method 5

As mentioned by SonicTheLichen, if you are publishing from Visual studio, the gloabal.asax file is not copied by default. By copying the global.asax to your webserver should resolve the issue. Thanks SonicTheLichen for proving the solution.

Regards,
Saurabh

Method 6

I don’t know if this will fix your issue, but it fixed one I had deploying and MVC app to IIS.

I had to add a wildcard application map to the aspnet_isapi.dll for the home/virtual directory of the application. You can do this by right clicking on the web site/virtual directory and selecting the home directory/virtual directory tab, clicking the configuration button and then click the Insert button under the wildcard application maps section.

C:WINDOWSmicrosoft.netFramework64v4.0.30319aspnet_isapi.dll

Good luck!

Method 7

I had a similar problem. I had to deploy a .net MVC site to a new server with Windows 2008 and IIS 7.5 installed. When I checked the programs and features, I saw that only the .Net Framework 4.5.1 was installed. I manually enabled the .Net 3.5.1 Windows feature. After I installed MVC 4.0 the routing did not work.

My solution:
1) Deinstall the .Net 4.5.1 framework and MVC 4.0
2) Install the .Net Framework 4.0
3) Install .Net framework 4.5.1
4) Install MVC 4.0

Method 8

I know this is old, but windows updates just now wasted a couple of hours for me:

IF you handle your exceptions in Global.asax this can also be simple as keeping windows updates the same as your dev env… For me, i did not obviously, this resulted in a “could not load….” exception, which my global.asax tried to handle and in turn had the same problem but hiding the underlying problem…..

Method 9

I had to enable scripts in the Handler Mapping section of the website properties in IIS.

Handler Mappings

Open IIS, click on the website in question. Open up Handler Mappings and click “Edit Feature Permissions”. Check the boxes for Script and Execute, then click OK. Good to go!


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x