views:

188

answers:

3

I deployed my first ASP.NET 4.0/MVC 2 application onto a staging and test server. The problem is that when I browse to the application I just get the ASP.NET 404 "The resource cannot be found." page.

The application was written using:

  • Visual Studio 2010 Premium
  • Target Framework: .NET 4.0
  • ASP.NET MVC 2.0

The application is deployed onto a Windows 2008 R2 server. ASP.NET 4.0 and ASP.NET MVC 2 are installed. The application is running in a 32-bit application pool configured for .NET 4 and running in Integrated Mode.

I've tested this application on my dev machine running Windows 7 Ultimate using both the VS Cassini server and IIS 7.5 and it works just fine.

Update - some additional notes about deployment

I deployed the application by right clicking on the project and selecting 'Publish'. I published to a local folder (Publish method: File System) on my dev PC and only published "Only the filesneeded to run this application".

I then FTP'd these files to the server. The application is running on the root of the website. I also tried deploying into a subfolder (with an application created for this in IIS).

Screen Shot: alt text

What can I have missed?

A: 

Did you install .NET 4.0 after IIS? If so, remember to run aspnet_regiis /ir

This bit me a couple of times with MVC2.

Andrew Robinson
.NET 4 is installed correctly (you can tell from the screenshot). I deleted the site and deployed the default sample project you get when you do a "New Project" in VS. That works, so I'm thinking this is actually a routing problem in Global.asax.cs
Kev
A: 

Have you got any escaped characters in the URL? eg. http://mysite/Controller/Action/this%25could%2fcause%2dproblems

baldrick
Nope, nothing like that.
Kev
A: 

I took this back to basics and built and deployed the sample MVC project that Visual Studio creates when you do:

File -> New Project -> ASP.NET MVC 2 Web Application (Targeting: .NET 4.0)

This worked just fine so the problem was either a routing issue or something up with my web.config file.

My application's project originally targeted .NET Framework 3.5 and I switched that over to target .NET Framework 4.0 at some point in time during development.

My suspicion is that a configuration setting in the web.config was causing ASP.NET or MVC routing to fail. I already had to hack about with the file because the config file contained duplicate configuration sections that ASP.NET 4.0 now provides as defaults in the machine wide web.config.

In the end I deleted my web.config, copied the clean one from the sample project above and dropped in my SQL connection strings. I then re-deployed and hey-presto the application ran properly.

Kev