码迷,mamicode.com
首页 > Web开发 > 详细

asp.net mvc 中使用静态页

时间:2015-03-18 15:38:21      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

方法1:

在Global.asax文件中增加

protected void Application_BeginRequest(object sender, EventArgs e)
{
    if (Context.Request.FilePath == "/") Context.RewritePath("index.html");
}

方法2:

新建一个路由DefaultController,并把它设置为默认路由,在Action中增加

Redirect(Url.Content("~/index.html"));

此方法需要修改web.config配置

在Web.config文件中的<compilation>节点中增加:

     <buildProviders>
        <add extension=".htm" type="System.Web.Compilation.PageBuildProvider" />
      </buildProviders>

  

方法3:

1)站点根目录增加了default.html;

2)修改Global.asax默认的路由注册,去掉默认controller:

routes.MapRoute(
                "Default", // 路由名称
                "{controller}/{action}/{id}", // 带有参数的 URL
                new {action = "Index", id = UrlParameter.Optional } // 参数默认值
            ); 

 

将iis中的默认文档配置为index.html

asp.net mvc 中使用静态页

标签:

原文地址:http://www.cnblogs.com/mhdtysp/p/4347214.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!