因为开发的电脑是win7 , 服务器是2003,在使用 Intelligencia.UrlRewriter 做伪静态时会有所不同,要适当修改。
但现实了就好,其实.net4之后的mvc已经完全可以不使用使用伪静态的,它不但有友好的url和路由,而且还有更加优秀的设计
模式和开发感受,更加趋于敏捷。
只不过网上太多的空间都不支持mvc,99.9%的.net空间不支持mvc,倒是支持伪静态的空间占60%,所以虚拟主机来说,
伪静态实现一些。
iis7不需要修改iis配置,只需要在web.config中配置一些东西即可。
<?xml version="1.0"?>
<!--
注意: 除了手动编辑此文件,还可用
Web 管理工具配置应用程序设置。可使用
Visual Studio 中的“网站”->“Asp.Net 配置”选项。
所有设置和注释都列在
machine.config.comments 中,该文件通常位于
\Windows\Microsoft.Net\Framework\vx.x\Config 中
-->
<configuration>
<configSections>
<!--UrlRewriter-->
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<appSettings/>
<connectionStrings>
<add name="Connstr2" providerName="System.Data.OleDb" connectionString="Provider=Microsoft.jet.oledb.4.0;Data Source=|DataDirectory|shw2013.mdb;" />
</connectionStrings>
<rewriter>
<rewrite url="^~/kb/(\d+).html" to="~/kb.aspx?Id=$1" processing="stop" />
<rewrite url="^~/news/(\d+).html" to="~/shownews.aspx?Id=$1" processing="stop" />
<rewrite url="^~/xueyuan/(\d+).html" to="~/showprodct.aspx?Id=$1" processing="stop" />
</rewriter>
<system.web>
<!--UrlRewriter Windows 2003 IIS 6 Config Setting-->
<!--<httpModules>
<add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter" />
</httpModules> -->
<!--
设置 compilation debug="true" 可将调试符号插入
已编译的页面中。但由于这会
影响性能,因此请仅在开发过程中将此值
设置为 true。
-->
<compilation debug="true"/>
<!--
通过 <authentication> 节,可配置
ASP.NET 用于识别进入用户的
安全身份验证模式。
-->
<authentication mode="Forms">
<forms name="login" loginUrl="/Admin/Login.aspx"></forms>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<!--
通过 <customErrors> 节,可以配置
在执行请求的过程中出现未处理的错误时要执行
的操作。具体而言,
开发人员通过该节可配置要显示的 html 错误页,
以代替错误堆栈跟踪。<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
--></system.web>
<system.webServer>
<!--UrlRewriter Windows 7 II7 Config Setting-->
<modules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" preCondition="" />
</modules>
</system.webServer>
<location path="Admin">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
配置中有iis7和iis6两种区别设置,现在注释了iis6的,如果换ii6上,就注释掉iis7的,启用iis6的。
![]()
![]()
但是iis6,还需要修改一下站点中扩展名的映射的设置,
1.右键点击 要设置网站的网站
2.属性 ——》主目录 ——》配置——》
3.如右侧窗口,找到 .aspx 扩展名——》编辑——》复制 可执行文件的路径——》关闭
4.点击 添加——》粘贴 刚复制的 可执行文件路径
5.扩展名填写 .html (如果是 .htm 或者 任意你想要的扩展都可以 前提是以后的应用程序扩展列表里边没有该扩展)
6.不选中 确认文件是否存在
7.确定
本列纯属于笔记,参考来源
http://www.cnblogs.com/yanzhen/archive/2012/01/07/2315579.html
http://www.cnblogs.com/yanzhen/archive/2012/01/07/2315534.html