方法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>

PS:iis设置的默认文档优先级要比web.config配置的默认文档高。

最新文章

  1. Delphi中字符串补齐方法
  2. html生成图片并保存到本地方法(Windows)
  3. form表单及其中元素
  4. PHP发送请求头和接收打印请求头
  5. 【转载】COM多线程原理与应用
  6. 关于resolve非泛型方法不能与类型实参一起使用
  7. Linux美化——终端提示符
  8. Linux shell 脚本中”2&gt;&amp;1″的含义解释
  9. CSS3学习系列之背景相关样式(一)
  10. Collections.synchronizedMap()、ConcurrentHashMap、Hashtable之间的区别
  11. shell打印 倒等腰三角形
  12. mysql常用
  13. telnet操作memcache
  14. quartz demo01
  15. 禁止textarea拉伸
  16. css3 box-sizing详解。
  17. [转] javaweb学习-jstl-&lt;c:forEach&gt;中 varStatus的属性简介
  18. restful_framework之APIView
  19. MemSQL Start[c]UP 2.0 - Round 1 E - Three strings 广义后缀自动机
  20. 如何在两个月的时间内发表一篇EI/SCI论文-我的时间管理心得

热门文章

  1. 20165219 2017-2018-2 《Java程序设计》第7周学习总结
  2. 洛谷P2762 太空飞行计划问题(最小割)
  3. 用shell脚本安装apache
  4. postgreSQL PL/SQL编程学习笔记(一)
  5. java技术
  6. _.each _.map _.filter javascript 语法
  7. shell-002:统计IP访问量
  8. springboot配置文件的所有属性
  9. asp.net MVC中的@model与Model
  10. 建立ionic3的环境