mvc伪静态<四> 伪静态后静态页面或者引用的css和图片失效

引用的css和图片失效的解决办法

把样式引用文件的相对路径改成绝对路径就可以了

比如原先的引用路径为:<link href="~/Content/css/style.css" rel="stylesheet" type="text/css" />

改成:<link href="http://www1.lvyou.edushi.com/Content/css/style.css" rel="stylesheet" type="text/css" />

静态页面实现的解决办法

在webconfig添加的相应的配置

需要对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"/>
原文地址:https://www.cnblogs.com/sunxi/p/4222276.html