当前位置:编程学习 > C#/ASP.NET >>

ASP.NET URL重写问题

我利用Intelligencia.UrlRewriter.dll实现URL重写,但是当我上传到空间时,那些连接都变得无效,都说找不到页面,怎么办,在VS2005里调试就没问题,但是到了空间那里就出问题了,为什么?各位大虾帮帮忙!如果能在明天下午前及时解决这个问题,加分至200分哦~~~~~
web.Config文件里的url重写内容:
<configSections>
<!--UrlRewriter-->
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
          </configSections>
<rewriter>
     <rewrite url="~/dipole/PL(.+)$" to="~/dipole/product.aspx?id=$1"/>
    <rewrite url="~/dipole/A$" to="~/dipole/us.aspx"/>
    <rewrite url="~/dipole/B$" to="~/dipole/organization.aspx"/>
    <rewrite url="~/dipole/C$" to="~/dipole/culture.aspx"/>
    <rewrite url="~/dipole/D$" to="~/dipole/product.aspx"/>
    <rewrite url="~/dipole/E$" to="~/dipole/case.aspx"/>
    <rewrite url="~/dipole/EL(.+)$" to="~/dipole/caseShow.aspx?id=$1"/>
    <rewrite url="~/dipole/Q(.+)$" to="~/dipole/FAQShow.aspx?id=$1"/>
</rewriter>
<system.web>
<httpModules>
<add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter"/>
</httpModules>
</system.web> --------------------编程问答-------------------- 参考 --------------------编程问答-------------------- --------------------编程问答-------------------- 你上传的虚拟空间不允许你修改iis吧?

一、如果是租用主机可以自己配置成本机一样的环境即可。当然也可以用ISAPI_Rewrite

二、否则可以考虑用微软的UrlRewriter,跟你的规则类似
说明:http://blog.csdn.net/bobo_keke/archive/2008/03/27/2224176.aspx

直接下载MS的URLRewriter.dll,放到你的web程序的bin下
下载地址1:http://www.rickel.cn/uploads/DevTools/MSDNURLRewriting.msi
下载地址2:http://download.microsoft.com/download/0/4/6/0463611e-a3f9-490d-a08c-877a83b797cf/MSDNURLRewriting.msi

--------------------编程问答-------------------- 没有这样写过
帮顶 --------------------编程问答-------------------- 没用过这个,就用过微软的URLRewriter.dll --------------------编程问答-------------------- IIS的默认ISAPI没解析你URL的扩展名,因为不认识它们,你得配置IIS
或者用微软那个 --------------------编程问答-------------------- 关注下 --------------------编程问答-------------------- 实在无奈,改用URLRewriter.dll。
<RewriterConfig>
    <Rules>
      <RewriterRule>
        <LookFor>~/dipole/PL(\d+)</LookFor>
        <SendTo>~/dipole/product.aspx?id=$1</SendTo>
      </RewriterRule>
    </Rules>
</RewriterConfig>
在<LookFor></LookFor>里我想把URL重写为不带后缀的地址,即不带.aspx,例如上面的product.aspx重写为PL(\d+)\,但是好像不行,好像必须带上.aspx,有哪位高手指点指点!帮帮忙阿!200分啊! --------------------编程问答-------------------- 在线等阿。。。。。。。。。。。。。。 --------------------编程问答-------------------- 给你一个实质性的解决方案,非常简单,请服务器商在IIS上添加映射,
网站右键-->主目录-->配置-->下面有个通配符映射,点击添加,找到系统盘,找到aspnet_isapi.dll,(这个不知道在哪的网上查)-->添加,然后去掉“检查文件是否存在”的选项,
就可以了
这个也可以解决urlmapping,因为如果有用过urlMapping也会存在你这样的问题
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,