2

经过测试,我已经完成了一个 ASP.NET 网站。

我正在使用来自http://www.urlrewriting.net/的 UrlRewritingNet dll

然后我发布了它以上传我的服务器(安装了 Windows 7、IIS 7)。输入我网站的 URL 后,我得到 404 - Not found 错误。这是因为服务器端的配置缺失或错误。但我不知道该怎么做。

搜索了很多次,但找不到任何接近我的问题的东西。

最后一次机会,我在这里。你能帮我吗?

你可以在下面看到我的 web.config 内容:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <configSections>
        <section name="urlrewritingnet" requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter"/>
    </configSections>

<system.web>
        <httpModules>
            <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
        </httpModules>

        <compilation debug="true" targetFramework="4.0"/>
    </system.web>

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>

        <handlers>
            <remove name="PageHandlerFactory-ISAPI-4.0_32bit"/>

            <add name="PageHandlerFactory-ISAPI-4.0_32bit" path="*.aspx" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>

            <add name="reww" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>

            <add name="rewwibu" path="*.ibu" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32"/>
        </handlers>

        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>

    <urlrewritingnet configSource="ExternalRewrite.config"/>
</configuration>

这是我的新 Web.Config 文件:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <validation validateIntegratedModeConfiguration="false" />
        <rewrite>
            <rules>
                <rule name="GoAnasayfa">
                    <match url="^([_0-9a-z-]+)/Anasayfa.ibu" ignoreCase="false" />
                    <action type="Rewrite" url="Default.aspx?lang={R:1}" appendQueryString="false" />
                </rule>
                <rule name="GoIletisim">
                    <match url="^([_0-9a-z-]+)/Iletisim.ibu" ignoreCase="false" />
                    <action type="Rewrite" url="Contact.aspx?lang={R:1}" />
                </rule>
                <rule name="GoDereceProgramlari">
                    <match url="^([_0-9a-z-]+)/DereceProgramlari/([_0-9a-z-]+).ibu" ignoreCase="false" />
                    <action type="Rewrite" url="DegreePrograms.aspx?lang={R:1}&amp;derece={R:2}" />
                </rule>
                <rule name="GoOgrenci">
                    <match url="^([_0-9a-z-]+)/Ogrenci.ibu" ignoreCase="false" />
                    <action type="Rewrite" url="Ogrenci.aspx?lang={R:1}" />
                </rule>
                <rule name="GoKatalog">
                    <match url="^([_0-9a-z-]+)/([0-9]+)/([0-9]+)/([0-9])/Katalog.ibu" ignoreCase="false" />
                    <action type="Rewrite" url="Catalog.aspx?lang={R:1}&amp;opID={R:2}&amp;pmID={R:3}&amp;oid={R:4}" />
                </rule>
                <rule name="GoDersDetay">
                    <match url="^([_0-9a-z-]+)/([0-9]+)/([0-9]+)/([0-9])/([0-9])/DersAyrintilari.ibu" ignoreCase="false" />
                    <action type="Rewrite" url="CourseDetail.aspx?lang={R:1}&amp;opID={R:2}&amp;pmID={R:3}&amp;DersID={R:4}&amp;dersKodu={R:5}" />
                </rule>
                <rule name="GoLLPKoordinatorleri">
                    <match url="^([_0-9a-z-]+)/LLPKoordinatorleri.ibu" ignoreCase="false" />
                    <action type="Rewrite" url="Coordinators.aspx?lang={R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

当我输入我的网址时,地址栏充满了 lang 参数,如下所示:

http://somedomain.com/tr-TR/Anasayfa.ibu?lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr&lang=tr-tr....

然后浏览器显示错误消息:

无效的重定向 URL

4

2 回答 2

10

尝试添加:

<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/>
<remove name="Session"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>

到你的web.config

<configuration>
  ...
  <system.webServer>
    ... 
    <modules>
      <!-- add here -->
    </modules>
  </system.webServer>
  ...
</configuration>
于 2013-10-15T08:17:47.407 回答
1

为什么不使用 Microsoft 的 URL 重写模块?
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module

请务必根据您的系统设置安装正确的版本。然后您可以继续创建重写规则,如下所示:
http ://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

于 2013-05-29T12:17:06.657 回答