I have an ASP.NET Web Forms website that uses .NET 4 routing to handle custom URLs.
Somebody in our organisation decided to advertise a URL with a plus sign in it (eg. www.domain.com/this+that), so now I am stuck with having to modify the system to recognise this URL and route it to the correct page.
It's a .NET 4.0 website running on IIS7.5.
I have researched how to do this already, and the advice has been to add the following to my web.config file, which I have done. But still I get a IIS 404 error message, and it doesn't even go to my custom 404 error page.
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true">
</requestFiltering>
</security>
</system.webServer>
Any idea why this isn't working?
I can only speak from personal experience, but try one of these:
MVC:
[ActionName("this+that")]
public ActionResult ThisThat()
{
return View("ThisThat");
}
web.config redirect:
<location path="this+that">
<system.webServer>
<httpRedirect enabled="true" destination="www.domain.com/this_that" httpResponseStatus="Permanent" />
</system.webServer>
</location>
Update: Working on my end. Make sure web.config looks like this:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
</system.webServer>
And Global.asax should look like the following:
protected void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("Test", "This+That", "~/Test.aspx");
}