zoukankan      html  css  js  c++  java
  • MVC利用URLRoute实现伪静态后正真的静态html无法访问

    MVC通过URLRoute让网站某些页面成为伪静态

                //Mall/SomeNews/12.html
                routes.MapRoute(
                    "News",                                              // Route name
                    "Mall/{action}/{id}.html",                           // URL with parameters
                    new { controller = "Mall", action = "NewDetails", id = "1" }  // Parameter defaults
                );

    --------------------------------------------------------------------------------

    win7+IIS7 测试一切正常

    --------------------------------------------------------------------------------

    win2003+iis6 测试不正常

    对iis做如下配置:

    主目录---应用程序设置下面配置---添加

    可执行文件:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll

    扩展名:.html

    动作:GET,HEAD,POST,DEBUG

    脚本引擎打勾,确认文件是否存在去掉

    -----------------------------------------------------------------------------

    此时似乎html都交给MVC处理了   但是新的问题来了,正真的静态页面Link.html无法访问了

    需要对web.config做如下配置:

    1.找到<compilation >节点

    加入如下内容最终结果

        <compilation debug="false">
          <buildProviders>
            <add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
          </buildProviders>
        </compilation>

    2.找到<httpHandlers>节点

    插入如下内容

        <add verb="*" path="*.html" type="System.Web.UI.PageHandlerFactory"/>

    ----------------------------------------------------------------------------

    此时一切OK 静态和伪静态都能正常访问

  • 相关阅读:
    shell数组
    Apache HTTP Server 与 Tomcat 的三种连接方式介绍
    实现Java动态类载入机制
    Tomcat 阀
    MYSQL 常用命令
    MYSQL字符数字转换
    主题:MySQL数据库操作实战
    日本手机三大代理商的UA
    Java解析XML文档——dom解析xml (转载)
    MS sql server和mysql中update多条数据的例子
  • 原文地址:https://www.cnblogs.com/JangoJing/p/1875861.html
Copyright © 2011-2022 走看看