2013-10-23 68 views
2

我有一个问题,有人发布了我的asp.net mvc3网站的网址,其中包含%3D而不是等号后的id参数如下:http://ultimategamedb.com/Article/Article?id%3D398210c1-529e-4909-9793-a11b8a832dcc。我尝试了各种重写规则,但似乎无法正确重写为:http://ultimategamedb.com/Article/Article?id=398210c1-529e-4909-9793-a11b8a832dcc。这是一个问题,因为带有%3D的网址会给出404错误。如果可能的话,我想创建一个规则,用%编码将任何URL重写为正确的解码值。如果这是不可能的,我只想知道如何重写我的文章网址,以确保%3D永远不会再次显示文章网址中的等号。IIS URL重写URL链接与%3D

任何人都可以向我解释我将如何去创建这些重写规则?提前致谢!

回答

2

您有几种选择:

  1. 写自己的供应商将取代%3D=

    参考:http://www.iis.net/learn/extensions/url-rewrite-module/developing-a-custom-rewrite-provider-for-url-rewrite-module

  2. Application_BeginRequest,更换您的路径:

    protected void Application_BeginRequest(object sender, EventArgs e) 
    { 
        string path = HttpContext.Current.Request.Url.PathAndQuery; 
    
        // Search for %3D and replace. 
        path = path.Replace("%3D","="); 
    
        HttpContext.Current.RewritePath(path); 
    }