asp.net(c#)2.0 开发webform看了一些关于URLRewriter的资料后,想要通过URLRewriter.dll来实现URL重写,我调试了一下,就是没有反应啊!我说一下我的实现办法,请帮忙看看问题出现再哪里:1、将URLRewriter.dll,放到的web程序的bin下2、配置web.config文件,代码如下:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections> <RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/d(\d+)\.aspx</LookFor>
<SendTo>~/GoodInforRead.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig> <system.web>
<httpHandlers>
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
</system.web>按照我的理解(也许理解有误,请指正),上面两步做完后应该能实现以下的功能:输入:http://localhost:2663/hh56web/15.aspx
转到:http://localhost:2663/hh56web/GoodsInforRead.aspx?id=15但是实际调试时,我输入http://localhost:2663/hh56web/15.aspx,出现错误提示“找不到15.aspx页面”请帮忙看看问题出再哪里???谢谢!!学习,关注…………
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections> <RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/d(\d+)\.aspx</LookFor>
<SendTo>~/GoodInforRead.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig> <system.web>
<httpHandlers>
<add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>
</system.web>按照我的理解(也许理解有误,请指正),上面两步做完后应该能实现以下的功能:输入:http://localhost:2663/hh56web/15.aspx
转到:http://localhost:2663/hh56web/GoodsInforRead.aspx?id=15但是实际调试时,我输入http://localhost:2663/hh56web/15.aspx,出现错误提示“找不到15.aspx页面”请帮忙看看问题出再哪里???谢谢!!学习,关注…………
解决方案 »
- 求翻译!java==>.Net
- sso的单点退出该怎么实现?
- asp.net缓存有哪些?
- 【求推荐】2005下。。Web打印报表用什么工具好。
- 为什么Response.Write("<script>alert('ok');</script>")会导致样式变乱?
- 这个问题看看谁能帮给解决一下
- 水晶报表推模式下怎么连接oracle数据库呀
- 强制页面刷新,当Session丢失的时候
- 在服务器上有一JPG文件,我指定该图片将要显示的高度,如何将对应的宽度按比例显示?
- 从asp将数据导入到word中出现问题
- WebHtmlEditor 1.7图片上传的方式问题,急啊,求大家帮助
- 在GridView中怎么得出里面有多少"项"?
<RewriterRule>
<LookFor> ~/d(\d+)\.aspx </LookFor>
<SendTo> ~/GoodInforRead.aspx?id=$1 </SendTo>
</RewriterRule> LookFor表达式有问题d(\d)
转到:http://localhost:2663/hh56web/GoodsInforRead.aspx?id=15
应该没有hh56web才能正确转向~
你应该是直接右键预览了。如果是xp你可以把iis主目录设置到你的hh56web项目下,如果是2003或者vista的话直接在iis下新建个网站就行然后用iis预览。
输入:http://192.168.0.9/15.aspx
没有转到:http://192.168.0.9/GoodsInforRead.aspx?id=15而是出现以下错误信息:“/”应用程序中的服务器错误。 无法找到资源。 说明: HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。 请求的 URL: /15.aspx
请大家再帮忙看看!!!!
<RewriterRule>
<LookFor> ~/(\d{1,})\.aspx </LookFor>
<SendTo> ~/GoodInforRead.aspx?id=$1 </SendTo>
</RewriterRule> 要仔细,这种问题一般都是串的问题,URLRewriter一般不会出错
<SendTo> ~/GoodInforRead.aspx?id=$1 </SendTo> 把lookfor里的改成别的后缀,以html为例:在iis里要加上对.html的解析。检查文件是否存在的选项不能选!这样应该可以了!!
<SendTo>~/GoodInforRead.aspx?id=$1</SendTo>
正则表达式写错,不然你要输入d15.aspx才能转向