Reputation: 28624
I'd like to deploy my ASP.NET MVC application to a web hosting company (like DiscountASP.net). I'm confused about what needs to be in the web.config file on the web server. When I create the project locally, I get a bloated web.config with all sorts of additional modules, handlers, compilers. Do I need to add all these items to the production web.config file?
I'm still deploying my current ASP.NET application (not MVC) in IIS6 and I've always hand crafted a simple web.config for the production environment and uploaded it with the rest of the application files. It seems like with IIS7 I'm meant to use the IIS Manager on the web server to build the web.config. What's the best way to build/manage the web.config on a production server?
Upvotes: 6
Views: 21267
Reputation: 28624
So here's what I've found so far trying to deploy my MVC application to DiscountASP.net.
The first think I found was that I had to make sure that System.Web.Mvc was deployed to the bin as it's not installed in the GAC:
http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx
Then I started with a super basic web.config that just contained the database connection string. My application did not work.
Then I copied the mess that's my local web.config up to the server and changed the database connection string and things started to work, but I was still getting the error message:
Could not load type 'System.Web.Mvc.ViewPage<MyCustomModel>'
Then I found this article that explains how you need to change the web.config to support not using code behind files (you don't need to do this with the local Visual Studio web server for some reason):
http://blog.benhall.me.uk/2009/01/aspnet-mvc-rc1-removing-code-behind.html
Personally, I don't like how simple application settings such as connection strings and SMTP settings are getting mixed in with complex MVC (and AJAX.NET) infrastructure settings. One nice option would be for the hosting company (such as DiscountASP.net) to set up the Master.config (or a higher level web.config) to support MVC, so that my web.config would only need to contain my simple application settings.
Upvotes: 6
Reputation: 5025
System.Web.Extensions is the MS AJAX AKA Atlas stuff, there are several modules and handlers and sections associated with this assembly. Feel free to remove them if you're not using the MS AJAX stuff.
Upvotes: 2
Reputation: 34573
.Net 3.5 and IIS7 both add quite a bit of text to the web.config. What I do is use the IIS Manager in IIS7 to configure the app once. Then I take that modified web.config and check it back in to source control. That way all of the IIS settings are preserved when migrating between environments.
Upvotes: 3
Reputation: 351758
Perhaps you take a search-and-destroy approach and chip away at the config until you have removed everything you don't need. Without knowing your application and its dependencies it is difficult to say what you may or may not need.
The best approach is to always have a development environment that mirrors your production environment as closely as possible - you don't want to be editing production configs in this way.
Upvotes: 1