我已经遵循了这个链接的所有步骤,包括网页。配置更改和添加所需的程序集。
ASP.Net and Webforms in Harmony
我已将MVC3安装到webforms项目中,并实现了一个控制器,并在Global的Application_Start method中注册了其路由。尽快。
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
这是控制器
public class HomeController : Controller
{
//
// GET: /Default1/
public ActionResult Index(int? id)
{
ViewData["Message"] = "Hello from Home controller";
return View();
}
}
为其他注册的路线。aspx表单运行良好。
routes.Add("Home", new Route("Home", new RoutingHandler("/Default.aspx")));