我已經遵循了此鏈接上的所有步驟,包括web.config更改和添加所需的程序集。
ASP.Net and Webforms in Harmony 我已經將MVC3安裝到webforms項目中,並實現了一個控制器並在Global.asax的Application_Start方法中註冊了它的路由。將MVC3集成到webforms - MVC路由不起作用
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();
}
}
我試圖調用它的動作(即/首頁/指數),但得到404 Not Found錯誤。
註冊其他.aspx表單的路由工作正常。
routes.Add("Home", new Route("Home", new RoutingHandler("/Default.aspx")));
一切工作正常,但(首頁/索引)沒有顯示出來。