3

In Visual Studio my project builds and runs with no problem. When deploying to Windows Server 2012 R2 I encounter the following error:

A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

I have installed all 4.5 and other Roles and Profiles, have given permission to the folder to everyone and have read every article and tried to implement every suggestion to no avail..

I'm out of options, spent weeks on this and cannot understand how this is so convoluted just to deploy a site.. Can someone advise? Thanks

Edit - this is for Windows Server 2012 and I have tried suggested alternatives such as adding runAllManagedModulesForAllRequests to my web.config.

Edit When deploying I build the solution in Release mode and copy the bin, views, content and scripts folders over to Windows Server. In IIS I then make the folder an application, making sure a 4.0 App Pool is assigned and still receive the error.

Final Edit Publish allowed me to see the structure that needed to be copied over. There were also 3 dll's that needed to be copied local from Visual Studio:

  • System.Web.Http.dll
  • System.Web.Http.WebHost.dll
  • System.Net.Http.Formatting.dll

As well as Web.Config dependentAssembly updated to take into account some MVC4 dll's such as Unity.Mvc4 pointing to MVC3 binaries.

InContext
  • 2,461
  • 12
  • 24
  • Often I find that the Default Document thing is a red herring. Go into your application pool settings in IIS for the application and change the .NET framework version to 4.** - it's often just set to use an older version of the framework, hence the problems. – adaam Jun 15 '15 at 22:13
  • possible duplicate of [ASP.NET 4.5 MVC 4 not working on Windows Server 2008 IIS 7](http://stackoverflow.com/questions/12495346/asp-net-4-5-mvc-4-not-working-on-windows-server-2008-iis-7) – Claies Jun 15 '15 at 22:13
  • this is no duplicate. The above is for WS 2008 and I tried to add the `runAllManagedModulesForAllRequests` but it did not help. In the App Pool I also already ensured the .NET version is set to 4... – InContext Jun 15 '15 at 22:20
  • Is the second "different error" that you posted the ***entire*** error, word for word? – Claies Jun 15 '15 at 22:33
  • and does `MySite.Web.MvcApplication` inherit from `System.Web.HttpApplication`? – Claies Jun 15 '15 at 22:37
  • Are you using an OWIN startup project that doesn't require a `Global.asax`? – Claies Jun 15 '15 at 22:39
  • this is the only error and above that "Parser Error Message: Could not load type 'MySite.Web.MvcApplication'". The type is definitely correct and I had to add the Global.asax manually by setting the Copy Local property. I am now testing with an out of the box MVC app by creating a new ASP.NET MVC app and copying the bin folder over to the server and making sure my WS 2012 R2 folder is setup as an application in IIS... – InContext Jun 16 '15 at 06:07
  • What settings did you use to publish the application? – Tieson T. Jun 16 '15 at 09:15
  • its my first MVC app and I just copy pasted the bin into its own folder (and then made this an application + assigned the 4.0 app pool) – InContext Jun 16 '15 at 09:44
  • 2
    Have you installed `ASP.Net` in IIS using `aspnet_regiis -i` from command prompt ? – Mairaj Ahmad Jun 18 '15 at 11:20
  • 1
    make sure mvc binaries are set to `CopyLocal = true` – Bart Calixto Jun 19 '15 at 03:35

3 Answers3

3

This error message gives a clue as to the problem. MVC sites do not rely on documents or web pages in the way that WebForms do, the default mode for IIS. They depend on a special handler that deals with the RESTful urls used to pass requests to your application.

In your web.config file, check that the following config is present in the system.webServer section:

<system.webServer>
  <handlers>
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <remove name="OPTIONSVerbHandler" />
    <remove name="TRACEVerbHandler" />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  </handlers>   
</system.webServer>

Then on your web server, open the IIS Manager, navigate in the Connections panel on the LHS to the node that represents your application, then double-click on the Handler Mappings icon in the Features View tab. Check that the ExtensionlessUrlHandler-Integrated-4.0 handler is enabled (see below).

ExtensionlessUrlHandler

If that doesn't do the trick, double-check that you have the ASP.NET 4.5 Role enabled on the server. See http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45#TOC301258515 for instructions.

Also make sure you application is running under an AppPool that is configured for .NET 4.0.

Paul Taylor
  • 5,651
  • 5
  • 44
  • 68
1

I recommend you to use Publish Tool in Visual Studio by right clicking on project in solution explorer to deploy resultant files on the web. Then try the followings:

  1. Reinstall .Net framework and MVC using Web PI.
  2. Put a dummy default.aspx file in the root folder (this will not be used when MVC is working, but can get rid of this problem).
  3. Try running the aspnet_regiis -i command in the Visual Studio 64 bit command prompt (with admin privileges), then deploy it.
  4. Take a look at Default Document configuration in IIS.

I wish to be solved.

Community
  • 1
  • 1
Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70
  • default document was required and also I had to copy local 3 of my dll's and update web.config to ensure that the depenentAssembly's were mapped to the correct dll versions. Publish allowed me to see the structure that I needed for deploying the project. Even with a fresh project on a fresh VS 2012 R2 server I still would see an issue with WebGrease. – InContext Jun 22 '15 at 05:55
0

Seems like IIS has not considered your application as a web application. It must be a MVC version mismatch.

As it is tagged as MVC4, we have 3 inner versions in MVC4. Check the server for which version of MVC is installed.If it is not installed or if you dont want to install MVC in the server, set CopyLocal=true for all the assemblies that you have referred in your project and re-publish the application and deploy in the server.

Venkatesan Rethinam
  • 143
  • 1
  • 3
  • 16