您需要包括3.0 System.Web.Mvc
版本。
在您的web.config中,您需要确保UrlRoutingModule
已注册为HttpModule。您的IHttpHandler
由IRouteHandler
实现创建,该实现在ASP.NET Mvc中为MvcRouteHandler
。
您还需要在您的Global.asax
中注册您的路线以设置路由。 (对于MVC2项目)的默认路由注册看起来是这样的:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
我不知道他们是否已经作出任何改变MVC 3或没有,但你可以通过创建一个新的MVC找出Web应用程序项目在Visual Studio中打开Global.asax