IIS URL Rewrite For URL Link with %3D
You have few options:
-
Write your own provider which will replace %3D with =.
-
In
Application_BeginRequest
, replace your path: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); }
Aaron Davis
Updated on June 04, 2022Comments
-
Aaron Davis almost 2 years
I am having an issue where someone has posted a URL for my asp.net mvc3 site that contains %3D instead of an equal sign after my id parameter like this: http://ultimategamedb.com/Article/Article?id%3D398210c1-529e-4909-9793-a11b8a832dcc . I have tried various rewrite rules but cannot seem the URL to rewrite correctly to: http://ultimategamedb.com/Article/Article?id=398210c1-529e-4909-9793-a11b8a832dcc . It is a problem because the URL with the %3D gives a 404 error. If possible I would like to create a rule that rewrite any URL with % encoding to the correct decoded values. If this is not possible I would just like to know how to rewrite my article URLs to ensure that a %3D will never show up for the equals sign in an Article URL again.
Could anyone explain to me how I would go about creating these rewrite rules? Thanks in advance!