MVC4.0 如何设置默认静态首页index.shtml
1.不启用二级域名情况下(www.xxx.com)下设置默认静态首页index.shtml
通过配置IIS的默认文档,设置默认首页地址

然后在MVC的路由中写入忽略默认路由代码
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "XXX.WebUI.Controllers" }//解决Controllers与Areas中控制器不能同名问题
);
2.启用二级域名情况下(xxx.xxx.com)下设置默认静态首页index.shtml
实现接口IRouteConstraint接口
public class DomainXXXXConstraint : IRouteConstraint
{
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
return httpContext.Request.Url.Host.ToLowerInvariant() == "XXXX";
}
}
然后在MVC的路由中写入忽略默认路由代码
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("", new { DomainConstraint = new DomainXXXXConstraint() }) routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "XXX.WebUI.Controllers" }//解决Controllers与Areas中控制器不能同名问题
);
}
MVC4.0 如何设置默认静态首页index.shtml的更多相关文章
- 在Tomcat7.0中设置默认服务器和不加端口名访问
前言 昨天买了域名,服务器,然后搭建了环境,然后想他通过默认的端口,不用端口就访问. 设置WEB项目的欢迎页 在WEB-INF文件夹下有个web.xml文件(最近新建的项目不包含此文件,可以手动新建) ...
- FastAdmin 怎么把模块设置默认的首页?
F4NNIU: 参考 ThinkPHP5 的路由设置. fangke-河南: 或者看config.php Karson:需要把插件设置为默认首页吗?在后台就可以,设置他插件的为伪静态,即可.
- cmake设置默认静态链接库
在使用cmake来编写CMakeLists.txt时,如果不特别指明,那么cmake是默认动态链接库的,最终生成的二进制文件只能在与本地相同环境下的机器运行,如果想把生成的二进制拷贝到其他机器上执行, ...
- MVC下设置默认页为index.html
将RouteConfig代码修改为如下 public class RouteConfig { public static void RegisterRoutes(RouteCollection rou ...
- asp.net core 设置默认文档index.html
参考:https://jingyan.baidu.com/article/6079ad0e3e212168fe86db75.html 在Startup.cs的Configure添加 app.UseFi ...
- 【Zend Studio】10.6.0版本设置默认字体
1.打开Windows->Prefefences 2.找到General->Appearance->Colors and Fonts->Basic->Text Font- ...
- 【Zend Studio】10.6.0版本设置默认编码为UTF-8
1.打开Windows->Prefefences 2.找到Workspace->Text file encoding,修改为UTF-8,OK保存.
- [QT]加快qt编译:设置默认多核编译qt
使用环境:win7 + QT Creator 4.2.1 + QT5.8 + MinGW5.3.0 32bit 设置默认多核编译qt 来源:http://stackoverflow.com/ques ...
- 设置java web工程中默认访问首页的几种方式
1.demo中最常见的方式是在工程下的web.xml中设置(有时候根据业务可能需要设置action,在action中处理逻辑加载跳转什么的,比较少): <welcome-file-list> ...
随机推荐
- 操作笔记:linux下安装mysql
1,检查linux下是否安装了mysql shell指令如下: [root@iZ945sgm0ugZ ~]# rpm -qa|grep -i mysql 如果有的话:做出挨个删除(eg:rpm -ev ...
- gitlb gerrit jenkins CI整合调试
- keepalive实现web服务器active/passive
https://github.com/acassen/keepalived/blob/v1.2.13/doc/keepalived.conf.SYNOPSIS http://ngyuki.hatena ...
- centos系统自动化安装研究
https://rhinstaller.github.io/anaconda/intro.html https://github.com/rhinstaller/pykickstart/blob/ma ...
- CSS 之 Opacity多浏览器透明度兼容处理
用来设定元素透明度的 Opacity 是CSS 3里的一个属性.当然现在还只有少部分浏览器支持. 不过各个浏览器都有自己的私有属性来支持,其中包括老版本的Mozilla和Safari: IE: fil ...
- Something wrong with FTK's index search results
My friend she told me last week that FTK could not "see" keywords in a plain text files wh ...
- 005windows与Linux文件共享
基于网络的文件共享: 前提一:从windows能够ping通Linux: 前提二:关闭Linux防火墙,命令[/etc/init.d/iptables stop]: 方法一:通过WinSCP 步骤一: ...
- PHP版实现友好的时间显示方式(例如:2小时前)
完整php类,通常我会配合smary使用,快捷使用 (plugins/function.rdate.php),更多php技术开发就去php教程网,http://php.662p.com <?PH ...
- IOS CLLocationManager定位反编码位置信息
//获取位置和坐标#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 if (IOS_VERSION >= 8.0) { ...
- 《深入剖析Tomcat》读书笔记(二)
三.容器Container Container 是容器的父接口,所有子容器都必须实现这个接口.Container 容器的设计用的是典型的责任链的设计模式,它有四个子容器组件构成,分别是:Engine. ...