【问题标题】:Create a rule with Service.Transfer() Behaviour IIS Rewriting Module使用 Service.Transfer() 行为 IIS 重写模块创建规则
【发布时间】:2011-09-01 15:14:16
【问题描述】:

是否可以创建一个行为类似于来自 ASP 的 Service.Transfer 的规则?

【问题讨论】:

    标签: asp.net iis url-rewriting iis-7.5 server.transfer


    【解决方案1】:

    使用 IIS7 重写模块,您可以使用 Rewrite Action

    这会保留原始 URL,但会以与 Server.Transfer 类似的方式重写您的应用程序将看到和处理的路径。

    <rewrite>
      <rules>
        <rule name="Rewrite to article.aspx">
          <match url="^article/([0-9]+)/([_0-9a-z-]+)" />
          <action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" />
        </rule>
      </rules>
    </rewrite>
    

    看看rules overview

    这本质上与Context.RewritePath 相同。

    【讨论】:

    • 问题是避免使用 Server.Transfer 并使用重写模块。对于 url 调用方式的性质,我不能使用 Server.Transfer!无论如何,谢谢你的建议! :)
    • 是的,对不起,我错过了标题中的 IIS URL 重写模块,我会修改。
    • 非常感谢,这非常有用:)
    猜你喜欢
    • 2014-02-02
    • 2018-02-01
    • 1970-01-01
    • 2012-11-05
    • 2016-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-12
    相关资源
    最近更新 更多