2

次のように、id パラメータの後に等号ではなく %3D を含む asp.net mvc3 サイトの URL を誰かが投稿したという問題があります: http://ultimategamedb.com/Article/Article?id%3D398210c1- 529e-4909-9793-a11b8a832dcc . さまざまな書き換えルールを試しましたが、URL を正しく書き換えることができません: http://ultimategamedb.com/Article/Article?id=398210c1-529e-4909-9793-a11b8a832dcc。%3D を含む URL では 404 エラーが発生するため、これは問題です。可能であれば、% エンコードの URL を正しいデコード値に書き換えるルールを作成したいと考えています。これが不可能な場合は、記事の URL の等号に %3D が再び表示されないように、記事の URL を書き換える方法を知りたいだけです。

これらの書き換えルールを作成する方法を誰かに説明してもらえますか? 前もって感謝します!

4

1 に答える 1

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);
    }
    
于 2013-10-25T18:35:01.357 に答える