简体   繁体   English

IIS集成管道模式下的ASP.NET URL重写

[英]asp.net url rewriting with IIS integrated pipeline mode

I am new to ASP.NET. 我是ASP.NET的新手。 I created a web application and decided to use url rewriting. 我创建了一个Web应用程序,并决定使用URL重写。 I tried several solutions like http://urlrewriting.net and http://urlrewriter.net/index.php/support/configuration 我尝试了几种解决方案,例如http://urlrewriting.nethttp://urlrewriter.net/index.php/support/configuration

These solutions worked fine on my localhost. 这些解决方案在我的本地主机上运行良好。 But when I uploaded it to a shared hosting service provider, all my web pages get 500 internal server errors. 但是,当我将其上传到共享托管服务提供商时,我所有的网页都收到500个内部服务器错误。

THe web hosting provider told me HttpModules and HttpHandlers are incompatible with IIS Integrated Pipeline mode. 一家网络托管提供商告诉我HttpModules和HttpHandlers与IIS Integrated Pipeline模式不兼容。 They said I'm supposed to move my settings into system.webServer...I tried doing that but must have messed up somewhere because I now get 404 errors. 他们说我应该将设置移到system.webServer中。我尝试这样做,但一定在某个地方搞砸了,因为现在我收到404错误。 Can someone tell me how to get url rewriting to work for my scenario? 有人可以告诉我如何使URL重写适合我的情况吗? Here's what my original web.config looks like: 这是我原始的web.config的样子:

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

  <system.web>
    <compilation debug="true" targetFramework="4.0"></compilation>
    <httpModules>
      <add name="UrlRewriteModule"
type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />

    </httpModules>
  </system.web>

  <urlrewritingnet
  rewriteOnlyVirtualUrls="true"
  contextItemsPrefix="QueryString"
  defaultPage = "default.aspx"
  defaultProvider="RegEx"
  xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >
    <rewrites>

      <add name="Rewrite"  virtualUrl="^~/([^\/]+)/(\d+)$"
      rewriteUrlParameter="ExcludeFromClientQueryString"
      destinationUrl="~/$1.aspx?id=$2"
      ignoreCase="true" />
      <add name="Rewrite"  virtualUrl="^~/(search|administrator|Default|logout)$"
      rewriteUrlParameter="ExcludeFromClientQueryString"
      destinationUrl="~/$1.aspx"
      ignoreCase="true" />

    </rewrites>
  </urlrewritingnet>

I think what they are saying is 我想他们在说的是

1) You have to use the rewriter in .NET 2) You have to set it up to use the URL Rewriter, which sits under system.webServer, not system.web. 1)您必须在.NET中使用重写器2)您必须对其进行设置以使用URL重写器,该URL重写器位于system.webServer而不是system.web下。

If I am correct, they are using the URL Rewriter: http://www.iis.net/download/urlrewrite 如果我是正确的,他们正在使用URL重写器: http ://www.iis.net/download/urlrewrite

NOTE: They may not allow your custom HTTP handler (yes, I know it is a published third party, but ISPs are funny like that). 注意:它们可能不允许您使用自定义HTTP处理程序(是的,我知道它是已发布的第三方,但是ISP像这样很有趣)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM