53

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.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_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.

Community
  • 1
  • 1
Dominic St-Pierre
  • 2,349
  • 2
  • 23
  • 34
  • Could you double confirm that the App Pool is running under the NETWORK SERVICE account? – Bart Verkoeijen Sep 19 '12 at 13:26
  • Yes the app pool uses NetworkService account (from the built-in dropdown list) – Dominic St-Pierre Sep 19 '12 at 13:32
  • Do you have Anonymous Authentication Enabled (or whatever Authentication you're planning on using)? – Mark Oreta Sep 19 '12 at 14:15
  • There is currently no restriction, this is a File -> New -> MVC 4 app, only changes so far is the _Layout template with CSS and renamed HomeController to PageController and route – Dominic St-Pierre Sep 19 '12 at 14:21
  • When I created a new site recently - it had all of the authentications disabled in IIS - enabling Anonymous Authentication fixed my issue. – Mark Oreta Sep 19 '12 at 14:24
  • Anonymous Authentication is Enable on IIS Authentication section, as well as Web Forms Authentication, on the Authorization section, All Users is Allow. Is there another place I should make sure those are OK? – Dominic St-Pierre Sep 19 '12 at 14:39
  • 2
    The error messages are the same as if the MVC framework was missing. You say there is an MVC3 app working on the server but you have no other working MVC4 app is there. I would suggest to look for the issue around the MVC4 framework installation and not the application settings. Also you can try to change you app pool settings (pipeline mode for example). – peterfoldi Sep 19 '12 at 14:51
  • 1
    Check to make sure anonymous authentication is using the app pool user. You do this by going into Authentication, right clicking on Anonymous and choosing Edit, then make sure the second radio button is checked. Alternatively, you can make sure the IUSR_* credentials are added to your sites folder. – Erik Funkenbusch Sep 19 '12 at 17:01
  • Why do you have System.Web.Handlers.TransferRequestHandler registered, isn't that for webforms (normally i just set runAllManagedModulesForAllRequests=”true”.)? Either way there may be a problem with that module as described here http://blogs.msdn.com/b/tmarq/archive/2010/05/26/how-extensionless-urls-are-handled-by-asp-net-v4.aspx – Betty Sep 29 '12 at 08:12
  • That may seem is stupid suggestion, but i do those kind of mistakes sometimes :) Do your physical path is IIS to your app entered correctly? I never had anithing special with deployment for years, so it is really something minor you've not done. Have you run aspnet_regiis for both x64 and x86 frameworks? – ADOConnection Oct 04 '12 at 15:10
  • Your simple app working on local machine right? – ADOConnection Oct 04 '12 at 15:14

9 Answers9

46

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.

kdrvn
  • 1,009
  • 1
  • 7
  • 10
  • Check EventViewer's application logs for an error. Check IIS logs from location C:\inetpub\logs for requests for a page. Next share these information here so will be easier to solve the problem. – jan salawa Oct 03 '12 at 17:11
  • this fix the problem, but why a out of the box web.config did not work as is. i.e. why am I forced to add this attribute, and is there any performance issue enabling this? Thanks – Dominic St-Pierre Oct 05 '12 at 17:54
  • 4
    This settings tells IIS to run managed modules for any requests, even for static requests (e.g.: images, .css, .js, ...), so it impacts the performances for those requests. You might want to read [this article for more informations](http://blogs.msdn.com/b/tmarq/archive/2010/04/01/asp-net-4-0-enables-routing-of-extensionless-urls-without-impacting-static-requests.aspx). The author of this article also provide another solution that you might want to try: [installing IIS7 QFE](http://support.microsoft.com/kb/980368). – kdrvn Oct 06 '12 at 16:48
  • IIS7 QFE does not install for Windows 8, what to do now? – Akash Kava Mar 19 '13 at 15:04
  • Windows 8 runs IIS8, not IIS7. Take a look at [this article](http://stackoverflow.com/questions/14025455/mvc-4-website-with-net-4-5-on-iis-8-in-windows-8-gives-403-14-forbidden-error). – kdrvn Mar 19 '13 at 15:33
  • We were running Windows Server 2008 with IIS 7 and .NET 4.5 adding `````` solved our problem. (So it's usefulness is not limited to 3.5 or below.) – JDwyer Jul 31 '13 at 22:28
  • Jeez, it's a year later and it still took me four hours to find this solution. IIS is such a waste of time. – xtravar Dec 11 '13 at 01:05
44

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>
Community
  • 1
  • 1
Martin Hollingsworth
  • 7,021
  • 7
  • 44
  • 49
  • Yes, this is the good way of fixing the issue, we bought a Win 2012 that worked fine, and I tried with your solution on the faulting Win 2008 and it work as expected. We are even going to keep the 2008 server now that it work without the runAllManageModulesForAllRequests. – Dominic St-Pierre Jan 31 '14 at 14:57
  • If you have a Windows 2008 Server with IIS 7.0 (not R2) then this is the download link for the hotfix: http://www.microsoft.com/en-us/download/details.aspx?id=11342 – Jonas Kello Mar 06 '15 at 16:49
  • Brilliant! Great success, very nice! – maxwellb Jul 26 '16 at 16:47
9

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.

Jesus Diaz
  • 165
  • 2
  • 8
2

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

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

Community
  • 1
  • 1
Daniel de Zwaan
  • 2,820
  • 23
  • 24
1

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

0

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:\WINDOWS\microsoft.net\Framework64\v4.0.30319\aspnet_isapi.dll

Good luck!

BlakeH
  • 2,904
  • 2
  • 16
  • 24
0

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

Patrick Koorevaar
  • 807
  • 12
  • 21
0

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.....

user1515791
  • 657
  • 4
  • 19
0

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!

BenM
  • 104
  • 5