【问题标题】:Programmatically Producing rewritten URLs?以编程方式生成重写的 URL?
【发布时间】:2012-05-31 16:35:34
【问题描述】:

在 ASP.NET 4.0 应用程序上使用 IIS 重写。我可以从 ASP.NET 中调用一些函数来将字符串 URL 转换为重写的 URL 吗?我希望能够在代码隐藏中做到这一点。

类似这样的:string ProduceRewrittenUrl(string publicUrl)

【问题讨论】:

    标签: asp.net iis url-rewriting


    【解决方案1】:

    是的,这是HttpContext.Current.RewritePath(string)

    参考: http://msdn.microsoft.com/en-us/library/system.web.httpcontext.rewritepath.aspx

    一个全球性的称呼它是global.asax上的protected void Application_BeginRequest(Object sender, EventArgs e)

    【讨论】:

      【解决方案2】:

      如果您想在代码中执行此操作,请查看使用 Global.asaxApplication_BeginRequest() 事件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-27
        • 1970-01-01
        • 2014-11-19
        • 1970-01-01
        • 2021-08-28
        • 1970-01-01
        • 1970-01-01
        • 2010-09-06
        相关资源
        最近更新 更多