<p>Where can I find some good pointers on best practices for running ASP.NET MVC on IIS6?</p>

<p>I haven't seen any realistic options for web-hosts who provide IIS7-hosting yet. Mostly because I don't live in the U.S.</p>

<p>So I was wondering on how you best build applications in ASP.NET MVC and make it easily available to deploy on both IIS6 and IIS7. Keep in mind that this is for standard web-hosts, so there is no access to ISAPI-filters or special settings inside IIS6.</p>

<p>Are there anything else one should think about when developing ASP.NET MVC-applications to target IIS6? Any functions that doesn't work?</p>

<p>UPDATE: One of the bigger issues is the thing with routes. The pattern {controller}/{action} will work on IIS7, but not IIS6 which needs {controller}.mvc/{action}. So how do I make this transparent? Again, <strong>no ISAPI</strong> and <strong>no IIS-settings</strong>, please.</p>

[{'answer_id': 34206, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 2, 'selected': False, 'text': '<p>With IIS6 you can do one of two things:</p>\n\n<ol>\n<li>Setup an ISAPI filter to map MVC URLs to ASP.NET</li>\n<li><a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true" rel="nofollow noreferrer">Include an extension in the URL</a>. For example: htp://localhost/Home.mvc</li>\n</ol>\n\n<p>Since option 1 is not available on most web-hosts, you have to go for number 2.</p>\n'}, {'answer_id': 34738, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 2, 'selected': False, 'text': '<p>You don\'t have to live with that extension if you can install an ISAPI filter on the server.</p>\n\n<p>Basically you route matched urls to the {controller}.mvc variety, then in ASP.NET you rewrite this url to remove .mvc -- doing this you don\'t have to define any extra routes or expose .mvc to your users.</p>\n\n<p>I\'ve written about this here:\n<a href="http://www.flux88.com/UsingASPNETMVCOnIIS6WithoutTheMVCExtension.aspx" rel="nofollow noreferrer">http://www.flux88.com/UsingASPNETMVCOnIIS6WithoutTheMVCExtension.aspx</a></p>\n\n<p>and Steve Sanderson has a good post here as well: <a href="http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/" rel="nofollow noreferrer">http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/</a></p>\n'}, {'answer_id': 35932, 'author': 'Sean Carpenter', 'author_id': 729, 'author_profile': 'https://Stackoverflow.com/users/729', 'pm_score': 3, 'selected': False, 'text': "<p>Since you can't modify IIS settings to map .mvc to ASP.Net, you can use a different extension that's already mapped to ASP.Net.  For example, you could use {controller}.ashx/{action} and it should work out of the box on IIS 6.</p>\n"}, {'answer_id': 40510, 'author': 'Jim Geurts', 'author_id': 3085, 'author_profile': 'https://Stackoverflow.com/users/3085', 'pm_score': -1, 'selected': False, 'text': '<p>I have a detailed step by step guide, but it requires that you use isapi_rewrite.  View it at: <a href="http://biasecurities.com/blog/2008/how-to-enable-pretty-urls-with-asp-net-mvc-and-iis6/" rel="nofollow noreferrer">http://biasecurities.com/blog/2008/how-to-enable-pretty-urls-with-asp-net-mvc-and-iis6/</a></p>\n'}, {'answer_id': 316015, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 5, 'selected': True, 'text': '<p>It took me a bit, but I figured out how to make the extensions work with IIS 6.  First, you need to rework the base routing to include .aspx so that they will be routed through the ASP.NET ISAPI filter.</p>\n\n<pre><code>routes.MapRoute(\n    "Default",                                              // Route name\n    "{controller}.aspx/{action}/{id}",                      // URL with parameters\n    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults\n);\n</code></pre>\n\n<p>If you navigate to Home.aspx, for example, your site should be working fine.  But Default.aspx and the default page address of <a href="http://[website]/" rel="nofollow noreferrer">http://[website]/</a> stop working correctly.  So how is that fixed?</p>\n\n<p>Well, you need to define a second route.  Unfortunately, using Default.aspx as the route does not work properly:</p>\n\n<pre><code>routes.MapRoute(\n    "Default2",                                             // Route name\n    "Default.aspx",                                         // URL with parameters\n    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults\n);\n</code></pre>\n\n<p>So how do you get this to work?  Well, this is where you need the original routing code:</p>\n\n<pre><code>routes.MapRoute(\n    "Default2",                                             // Route name\n    "{controller}/{action}/{id}",                           // URL with parameters\n    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults\n);\n</code></pre>\n\n<p>When you do this, Default.aspx and <a href="http://[website]/" rel="nofollow noreferrer">http://[website]/</a> both start working again, I think because they become successfully mapped back to the Home controller.  So the complete solution is:</p>\n\n<pre><code>public class MvcApplication : System.Web.HttpApplication\n{\n    public static void RegisterRoutes(RouteCollection routes)\n    {\n        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");\n\n        routes.MapRoute(\n            "Default",                                              // Route name\n            "{controller}.aspx/{action}/{id}",                      // URL with parameters\n            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults\n        );\n\n        routes.MapRoute(\n            "Default2",                                              // Route name\n            "{controller}/{action}/{id}",                            // URL with parameters\n            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults\n        );\n    }\n\n    protected void Application_Start()\n    {\n        RegisterRoutes(RouteTable.Routes);\n    }\n}\n</code></pre>\n\n<p>And your site should start working just fine under IIS 6.  (At least it does on my PC.)</p>\n\n<p>And as a bonus, if you are using Html.ActionLink() in your pages, you should not have to change any other line of code throughout the entire site.  This method takes care of properly tagging on the .aspx extension to the controller.</p>\n'}, {'answer_id': 1023346, 'author': 'PropellerHead', 'author_id': 103365, 'author_profile': 'https://Stackoverflow.com/users/103365', 'pm_score': 2, 'selected': False, 'text': '<p>As mentioned in this <a href="http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx" rel="nofollow noreferrer">blog post</a> by Phil Hack, it is possible to setup extension-less URLs for ASP.NET MVC in IIS 6 using <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true" rel="nofollow noreferrer">wildcard application mappings</a>:</p>\n\n<ol>\n<li>In IIS 6, go to the Application Configuration Properties for your ASP.NET MVC web application.</li>\n<li>Click "Insert..." in the Wildcard application maps section.</li>\n<li>Set the Executable to the path of the aspnet_isapi.dll (on my machine this is c:\\windows\\microsoft.net\\framework\\v2.0.50727\\aspnet_isapi.dll).</li>\n<li>Make sure NOT to check the "Verify that file exists" and click "OK".</li>\n</ol>\n\n<p>However as also mentioned by Hack, there are some performance implications of doing this.</p>\n'}, {'answer_id': 1788200, 'author': 'Alex Ilyin', 'author_id': 114103, 'author_profile': 'https://Stackoverflow.com/users/114103', 'pm_score': 1, 'selected': False, 'text': '<p>Url rewriting can help you to solve the problem. I\'ve implemented solution allowing to deploy MVC application at any IIS version even when virtual hosting is used.\n<a href="http://www.codeproject.com/KB/aspnet/iis-aspnet-url-rewriting.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/aspnet/iis-aspnet-url-rewriting.aspx</a></p>\n'}, {'answer_id': 2687318, 'author': 'anov', 'author_id': 181295, 'author_profile': 'https://Stackoverflow.com/users/181295', 'pm_score': 0, 'selected': False, 'text': '<p>I have a sample application on IIS6.</p>\n\n<p>I found quick-and-dirty solution. (Dirty, because it contains default view name with extension) It does not require additional route, or anything special. (Except, your default route must {controller}.aspx/{action}... format)</p>\n\n<p>Here the default.aspx</p>\n\n<pre><code>&lt;%@ Page Language="C#"%&gt;\n&lt;script runat="server"&gt;\nprotected void Page_Load(object sender, EventArgs e)\n{\n    HttpContext.Current.RewritePath("~/Home.aspx/index");\n    IHttpHandler httpHandler = new MvcHttpHandler();\n    httpHandler.ProcessRequest(HttpContext.Current);\n}\n&lt;/script&gt;\n</code></pre>\n\n<p>My sample applications default action was index, in Home directory.</p>\n\n<p>Note : I saw this code at Phil Haack\'s blog. Thanks to Brian Lowe.</p>\n'}]
['https://Stackoverflow.com/questions/34194', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2429/']