RegisterRoutes 注册路由示例配置:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(
name: "default",
url: "controller/{id}.htm",
defaults: new { controller = "Home", action = "Index" });
}
Controller 示例代码
public class HomeController : Controller
{
// GET: Home
public ActionResult Index(int id)
{
return View();
}
}
解决方式在 Web.config 中添加如下配置:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>