Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with a URL that ends with %20

I have a big problem. There are devices in live that send the URL "/updates ". It's a typo of the developer for those devices. In the server logs, it looks like "/updates+".

I have a ManageURL rewriting module that handles all requests without extension. But this request causes an HttpException:

System.Web.HttpException:

System.Web.HttpException
   at System.Web.Util.FileUtil.CheckSuspiciousPhysicalPath(String physicalPath)
   at System.Web.HttpContext.ValidatePath()
   at System.Web.HttpApplication.ValidatePathExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

As I see in the logs, the URL rewriting module does not even get this URL, so I cannot fix it there.

Is there a way to handle those URLs with ASP.NET?

like image 343
AlfeG Avatar asked Jul 14 '09 17:07

AlfeG


People also ask

Why does my URL have a question mark at the end?

Answer: This icon that looks like a diamond with a question mark in it indicates a space in the URL. Since spaces are not supported in a redirect URL, this icon displays to indicate why it will not work.

What is a bad URL?

A URL in your data feed is badly formed or contains invalid characters. There are several common reasons why you might receive this error: Your URLs contain spaces or symbols. Our system won't be able to process URLs containing spaces or certain symbols.

How do I check for URL errors?

There are two ways to access the URL Inspection tool:Type the URL to inspect in the inspection search bar at the top of any Search Console screen. Click an Inspect link next to a URL in most reports. Sometimes you might need to hover over a URL to see this option.


1 Answers

Ok, this is an old thread, but I like to add a workable solution that works for all ASP.NET versions. Have a look at this answer in a related thread. It basically comes down to registering to the event PreSendRequestHeaders in global.asax.cs.

Alternatively, when on ASP.NET 4.0 or higher, use <httpRuntime relaxedUrlToFileSystemMapping="true" /> in web.config.

like image 189
Abel Avatar answered Oct 19 '22 21:10

Abel