I just got a new Windows Server 2003 machine and I've been trying to get Nerd Dinner onto it. The server already has .NET 3.5 SP1, ASP .NET MVC, etc.
When I upload Nerd Dinner via FTP to a subdirectory of the main webpage, I get a 404 when I go to any page in the site except for the root and the home page doesn't event show the map.
For example, when I go to the about page, I get the following IIS log entry:
2009-08-13 17:56:10 18.104.22.168 GET /nerddinner/Home/About - 80 - 22.214.171.124 Mozilla/4.0+(compatible;+MSIE+8.0
<snip>) 404 0 3
I'm extremely puzzled because this is a freshly downloaded and compiled copy of Nerd Dinner from Codeplex.
2009-08-13 18:03:05 126.96.36.199 GET /Scripts/Map.js - 80 - 188.8.131.52 Mozilla/4.0+(compatible;+MSIE+8.0
<snip>) 404 0 3
I have a strong feeling that I should be able to fix this inside the asax.cs file but I can't quite get it to work even after appending "nerddinner/" to the front.
Any ideas for what's happening?
Edit: I uploaded it to the root of the webfolder and the 404s continue.
Edit 2: Thanks for the suggestions. I followed the instructions and now I don't get 404s. However, there are 2 major problems left:
- The scripts and content folders don't map correctly. I get 404s on all references to the files inside those folders.
- I can't view dinners at all. I get:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
and a line in red that says
"<connectionStrings configSource="ConnectionStrings.config" />". Except that ConnectionStrings.config doesn't exist on the server, so it wasn't an important file according to VS, and thus, I have no idea what the error is referring to.
(a quick search of my local hard drive turns up a ConnectionStrings.config file with nothing in it)
Now I think I'm getting the equivalent of a SQL Server 404 when I go to view dinners...
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Summary To Help Others Running ASP .NET MVC on IIS6, Especially Nerd Dinner:
- IIS 6 may throw piles of 404s at you because it doesn't understand that files can have no extensions. To solve that, follow the steps in Phil Haack's blog post.
- ASP .NET MVC URL rewriting is not magic. It only rewrites URLs that are piped through code. References to scripts, images, databases, direct links (aka a href tags; not the ones that are dynamically generated) etc. are not remapped based on the directory of your application. For the Nerd Dinner application, go through the pages and add "/nerddinner/" in front of references to these references. Substitute "nerddinner" with the name of your subdirectory.
- Take the database and attach it to SQL Server (or SQL Server Express) on your server. Add the Network User to the database with read/write roles.
Fill in the correct connection string for your setup. In my case, I was referring to the server by IP address and using SQL Server 2005 so my connection string is:
<add name="NerdDinnerConnectionString" connectionString="Data Source=184.108.40.206; Initial Catalog=NerdDinner; Integrated Security=SSPI" providerName="System.Data.SqlClient.SqlConnection"/>
The scripts and content folders don't map correctly. I get 404s on all references to the files inside those folders.
In ASP.NET MVC files do not map one for one to an URL, like they do in ASP.NET. Instead, a match in the routing table diverts a GET or POST request from the browser to a controller method in one of your controllers. From there, the controller decides (either explicitly or by convention) which View to display.
An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
ConnectionStrings.config needs to exist on the server, since it is being referenced in web.config. It's an include file, so there doesn't necessarily have to be anything in it. But if it is being referenced, it needs to be included on the server, so just copy it there with your FTP program.