1

.Net 2.0/IIS-7

I want to redirect

abc.com\GroupRequests\FirstGroup

to a handler abc.com\GroupRequests\grouprequesthandler.ashx but I want all *.aspx files in abc.com\GroupRequests\FirstGroup to be accessed using their original URL.

prefer config solution instead of code

4

1 回答 1

0

This solution uses URLRewriter which is available in IIS7. It is independent of your .net version.

<rewrite>
      <rules>
        <rule name="RewritePartner">
          <match url="^Partner/([A-Za-z]+)/(.+)" ignoreCase="false"/>
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
          </conditions>
          <action type="Rewrite" url="Handler/Partner.aspx?partner={R:1}&amp;query={R:2}"/>
        </rule>
      </rules>
    </rewrite>
于 2013-01-29T02:34:37.333 回答