Publishing an ASP.NET site to Windows 7 and IIS 7.5

I’ve just started developing a new ASP.NET MVC application on Windows 7 using IIS 7.5 and wanted to publish it to IIS. The steps are simple.

  • Right mouse click on your project and select Publish.. or select the Build menu and select Publish Selection.
  • If you do not have a profile select <New..> from the drop down and create one
  • Select Next and in my case I was deploying to a file system, so selected Publish Method: File System.
  • Browse to the target path (for example C:\inetpub\wwwroot\MyApp)
  • Set Destination URL to localhost
  • Select Next, I set this to Release configuration and delete all existing files prior to publish (obviously you choose what options you wish)
  • Select Next, the n Publish

The files and folders are copied and ready to access.

Now I was using a machine not yet set up correctly for hosting IIS and the first thing I got when trying to view http://localhost/MyApp was HTTP Error 403.14 – Forbidden. I needed to set Internet Information Services (IIS) Manager up to see the MyApp folder as an application.

  • So open IIS Manager and right mouse click on MyApp (under Sites/Default Web Site in my case).
  • Right mouse click on MyApp and select Convert to Application
  • Accept the defaults and press OK

Now reload the web page. If you get the following error in your browser Handler “ExtensionlessUrlHandler-Integrated-4.0” has a bad module “ManagedPipelineHandler” in its module list. Try opening a Visual Studio command  prompt as Administrator and type/paste

aspnet_regiis -i

(this should be available from C:\Windows\Microsoft.NET\Framework\v4.0.30319)

or to check if this is installed select the Application Pools in IIS Manager and you should see ASP.NET v4.0 (probably along with ASP.NET v4.0 Classic, Classic .NET AppPool and DefaultAppPool).

Now reload the web page and all should be working.

Note: For deploying ASP.NET MVC, make sure you set System.Web.Routing, System.Web.Mvc and System.Web.Abstractions to Copy Local = True as per documentation on http://msdn.microsoft.com/en-us/library/dd410407(v=vs.90).aspx