标签:
方法1:在RouteConfig.cs文件中配置默认路由
public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } }
方法2:在Global文件中添加方法
protected void Application_BeginRequest(object sender, EventArgs e) { if (Context.Request.FilePath == "/") HttpContext.Current.Response.Redirect("/home/about"); }
方法3:在web.config中配置节点;这个方法不支持路由,默认文档需放在网站根目录下,类型可以是.php, .asp, .htm, .aspx, .cfm等等
<system.webServer> <defaultDocument> <files> <clear/><!--防止在iis配置默认文档中冲突--> <add value="index.html" /> </files> </defaultDocument> </system.webServer>
标签:
原文地址:http://www.cnblogs.com/paulhe/p/4421822.html