The latest drop of ASP.NET MVC (Preview 2) enables you to deploy your app by simply uploading your assemblies and MVC dependencies to your bin directory and run in a partial trust. There's still one catch, however, if your host is running IIS 6 and you have no access to manage your web site IIS properties.
Since MVC routing employs a .mvc extension to identify incoming requests IIS needs to have a asp.net mapping to that extension. If you have no access to the IIS management tools you'll end up with a bunch of 404 errors. The real answer is to request a mapping for the .mvc extension from your host.
The hack, if you're impatient (like me) or if your host is unwilling to map that extension is to reuse the .aspx extension. In other words set up your routes in GlobalApplication.RegisterRoutes to use the .aspx extension rather than .mvc.
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add(new Route("Default.aspx", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new {controller = "Home", action = "Index", id = ""}),
});
routes.Add(new Route("{controller}.aspx/{action}/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new {action = "Index", id = ""}),
});
}
Note that you have to bump the default route up as the first route. This is because routing rules are evaluated in the order in which they are declared. The limitation of this method is that you can never have a controller called Default :-)
Friday, March 07, 2008
Deploy ASP MVC Preview 2 your Shared Host Environment
Subscribe to:
Posts (Atom)
