各位大虾们,小弟最近在搞asp.net的伪静态,弄了好长时间也实现不了,无奈求助各位高手
说明:我用的开发工具是 vs2008,web服务器是vs2008自带的。
具体做做法是这样的!
首先:下载并引用了URLRewriter.dll 这个文件。
其次:修改了Web.config文件
1.<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" /> //添加的节点
</configSections> 2. <RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/index.html</LookFor>
<SendTo>~/Default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Default2.html</LookFor>
<SendTo>~/Default2.aspx</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
3.<httpHandlers>
//一下是新添加的节点
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
请问各位大虾,小弟错在那里?。请各位不吝指教,小弟不胜感激!!!
说明:我用的开发工具是 vs2008,web服务器是vs2008自带的。
具体做做法是这样的!
首先:下载并引用了URLRewriter.dll 这个文件。
其次:修改了Web.config文件
1.<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" /> //添加的节点
</configSections> 2. <RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/index.html</LookFor>
<SendTo>~/Default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Default2.html</LookFor>
<SendTo>~/Default2.aspx</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
3.<httpHandlers>
//一下是新添加的节点
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
请问各位大虾,小弟错在那里?。请各位不吝指教,小弟不胜感激!!!
解决方案 »
- 不显示删除回复显示所有回复显示星级回复显示得分回复 [固定] UltraWebGrid 使用心得(2)![加精] (顶啊) 希望对新手有些帮助![问题点数:1
- 梅花雪3.0日期控件 网页上有错误..
- gridview问题
- 如何在子页面中调用父页面中的事件(很快揭帖)
- 散分,大家说说自己在使用.net2.0开发的过程中体会的好处。
- 还是xmlDocument和XPath的效率问题
- dataset未解决的问题再提问
- 如何在.net的后台程序里建立个临时表.当检索完后在删除,该如何做.急,在线等候!
- 请安装过Framework 2.0 Beta的朋友进来一下
- 大家进来帮帮忙
- vanadium的ajax 传递问题
- NavigationMenu 能不能实现按需要显示?
ActionlessForm.dll
URLRewriter.dll
真正实现重写的是 URLRewriter.dll 但是如果你要实现分页,那么必须使用这个ActionlessForm .dll
首先在web.config里写<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>
<!-- 下面是配置重写URL规则 -->
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/Products/Jurisdiction_(\w{3})\.aspx</LookFor>
<SendTo>~/En/Jurisdiction.aspx?jurid=$1</SendTo>
</RewriterRule> <RewriterRule>
<LookFor>~/Articles/(\d{1,})\.aspx</LookFor> <!-- 这个是被代替后的文件名,使用到正则表达式 -->
<SendTo><![CDATA[~/En/Article_view.aspx?article_id=$1]]></SendTo> <!-- 这个是要给代替的网页,一般是带有问号后面带参数的网页 -->
</RewriterRule>
<RewriterRule>
<LookFor>~/Articles/(\d{1,})_(\d{1,})\.aspx</LookFor>
<SendTo><![CDATA[~/En/Article_view.aspx?article_id=$1&page=$2]]></SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<LookFor>~/index.html</LookFor>
<SendTo>~/Default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Default2.html</LookFor>
<SendTo>~/Default2.aspx</SendTo>
这个用lookfor里面的后缀名为html的内部服务器是识别不了的,只有iis才能识别(并且iis还要配置)iis 配置
主目录=>应用程序配置=>通配符应用程序映射=>添加isapi.dll
你不会右键在浏览器查看吧?
这样肯定是.aspx结束啊你应该右键查看后把.aspx改成html看看可以正常访问不
包括网页里面的链接都要手工改的!
我前阵子也做伪静态,最麻烦的就是整个网站的链接了
我全部用完全路径去链接的,比如图片http://www.hao123.com/images/1.jpg
页面也是完全路径,如:http://www.hao123.com/index.html
http://www.xunxt.com/forum-viewthread-tid-63-fromuid-1.html