I have been doing a school project in MVC2 and .Net 4 for the last few weeks, and when the time came to deploy the web application to my host (surftown.dk) the fun began…
First Problem: host does not support .Net 4, reason? “The control panel does not support .Net 4”.
Solution: Somewhat easy downgrade to .Net 3.5, the only problem was Entity Framework 4.
Second Problem: MVC2 has not been installed on the host server.
Solution: Thanks to a post by Mr. Haackedthis was an easy fix, since you can deploy the MVC assemblies to the web applications bin folder (Full trust is not needed).
Third Problem: MVC2 routing has not been configured in the host IIS, aka “The website declined to show this webpage”
Solution: Change routing in Global.asax to use “{controller}.Mvc.aspx” instead of “{controller}”, this will trick IIS into routing as expected by MVC2.
Example:
From:
routes.MapRoute("ProfileSearch", "Profile/Search/{query}", new { controller = "Profile",
action = "Search" });
routes.MapRoute("Default", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
routes.MapRoute("ProfileView", "Profile/{nickName}", new { controller = "Profile",
action = "Index" });
To:
routes.Add(new Route("{controller}.mvc.aspx/{action}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { controller = "Home" })
});
routes.Add(new Route("{controller}.mvc.aspx/{action}/{query}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { controller = "Home", action = "Search" })
});
routes.Add(new Route("Profile.mvc.aspx/{nickName}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { controller = "Profile" })
});
The downside is that URLs are ugly ugly ugly.
From “/Profile/MyNickName” to “/Profile.mvc.aspx/MyNickName”