What decodes my encoded hash symbol(#)?

2019-02-17 18:51发布

问题:

We noticed that several machines have problems with URLs with hash parameters.

When debugging a request with the URL:
http://domain.com/Entity(%23{number-here}

We see in the Application_BeginRequest method in the global.asaxfile the URL: http://domain.com/Entity(#23{number-here} in Url.OriginalString and the Url.LocalPath has http://domain.com/Entity( and all the chars after the hash are in Url.Fragment.

When running exactly the same application on machines running Windows 8.1 and IIS 8.5 it works as expected, the Url.OrinalString is http://domain.com/Entity(%23{number-here}.

I can't see anything suspisous in the URL rewrite section in the web.config or in the IIS configuration.

What can be the reason for this behaviour?

回答1:

This is a bug in System.Web.dll. It is fixed on Windows 8.1, but we haven't yet rolled out a fix to System.Web.dll on downlevel versions of the operating system. We're trying to get a fix in for .NET 4.5.x for all supported OSes when the next reliability update comes out.



回答2:

Here's a workaround for older OS's until the bug fix is ported back. If you have the luxury of changing the URL, put the term that may contain a hash in a query string parameter, e.g.

http://domain.com/?entity=Entity(#23{number-here}