2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > mvc路由 html asp.net-mvc – ASP.NET MVC路由从html页面开始

mvc路由 html asp.net-mvc – ASP.NET MVC路由从html页面开始

时间:2021-09-03 05:51:12

相关推荐

mvc路由 html asp.net-mvc – ASP.NET MVC路由从html页面开始

我正在使用IIS 6.我想我的问题是我不知道如何使用routes.MapRoute路由到一个非控制器.

我有一个url,如,我希望它为index.htm页面提供服务,而不是使用MVC.我该如何设定?在IIS中,我将index.htm作为我的起始文档,我的global.asax具有标准的“默认”路由,其中​​它调用Home / Index.

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 = "" } // Parameter defaults

);

}

我补充说:

protected void Application_BeginRequest(object sender, EventArgs e)

{

if (Context.Request.FilePath == "/") Context.RewritePath("index.htm");

}

有用.但这是最好的解决方案吗?

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。