17

I have two languages on my site: en and de.

When I'm trying to open http://{HOSTNAME}/%20/ - I'm recieving error:

enter image description here

Question: How can I fix this issue and process this request in correct way?

7
  • Have you contacted Sitecore Support? It looks like a bug in their code Jan 19 '18 at 10:31
  • 1
    This error is the default behaviour of Sitecore. I don't understand what you are trying to achieve here. %20 is just an URL encoded Space character. What do you expect to happen? Do you have an item that has a Space as title? Jan 19 '18 at 10:33
  • 6
    I'm not the OP but I would expect 404 here Jan 19 '18 at 10:34
  • Sounds like IIS treats %20 as a virtual directory and inherits the Web.config from the "root site". Weird. Jan 19 '18 at 10:35
  • Sebastian Lay, I don't have item with white space title. Jan 19 '18 at 10:45
8
+50

As much as I hate to put this as an answer, but this is not a Sitecore issue.

this doesn't fail: http://sitecoredemo/sitecore/service/notfound.aspx/%20/

neither does http://sitecoredemo/sitecore/service/notfound/%20/

neither does http://sitecoredemo/sitecore/%20/

just http://sitecoredemo/%20/

I have tested this on IIS 7, IIS8, and IIS10. On Sitecore sites and non-Sitecore sites. All behave the same way.

From looking at Google, there are other people having this issue: https://stackoverflow.com/questions/26364213/asp-net-url-ending-in-20-is-not-getting-to-application-code https://our.umbraco.org/forum/using-umbraco-and-getting-started/79164-whitespace-in-url-causes-server-error

I suspect that this is either an IIS or URL Rewrite Bug... or an undocumented "feature" that serves a purpose.

Additionally, /%20/ is not just the trigger. I have tried numerous other encoded characters and all react the same way. There is something in IIS with respect to the unencoding of the URL that breaks the web.config configuration when serving the page.

On a side note.. if anyone wanted to clog up log files, this would be a fantastic way to do it.

So how to solve?

Honestly, aside from crazy QA test cases purposefully doing it... There shouldn't be anything happening that is redirecting a user to this type of URL unless you have an error in your URL Rewrite rules or bad redirect rules in your web application.

One search result netted a comment to add the following to the web.config, but this appears to also open up security issues.

<httpRuntime relaxedUrlToFileSystemMapping="true" />

How to Hide / Show Proper Error Page

Since the issue is with IIS, additional error page handling needs to be set up in the web.config.

<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="400" subStatusCode="-1" />
  <remove statusCode="404" subStatusCode="-1" />
  <remove statusCode="500" subStatusCode="-1" />
  <error statusCode="404" prefixLanguageFilePath="" path="/error" responseMode="ExecuteURL" />
  <error statusCode="400" prefixLanguageFilePath="" path="/error" responseMode="ExecuteURL" />
  <error statusCode="500" prefixLanguageFilePath="" path="/error" responseMode="ExecuteURL" />
</httpErrors>

This at least allows a proper error page to render, and not the default Yellow Screen of Death. (Thanks @jammykam for the comment)

1
  • 3
    This is an issue in IIS, and having a properly set up 500 error mitigates the issue, we resolved this issue with the same method: forums.asp.net/t/…
    – jammykam
    Feb 1 '18 at 2:18
7

You can use URL Rewrite module for your issue :

1) Open the Internet Information Services(IIS) Manager

2) Select “Your Web Site”

3) In the Feature View click “URL Rewrite“

4) In the “Manage Providers” pane on right hand side click on “View Rewrite Maps…” and then select "Add Rewrite Map.."

enter image description here

5)Set the map name, SpaceMap for example

6) In the “Actions” pane on right hand side click on “Add Mapping Entry…”

In the "Original value" field insert / /, in the “New Value“ set /404page and Click "Ok"

enter image description here

7) In the “Actions” pane click on “Add rule(s)…” and then select "Rule with rewrite Map" template

8) Leave “Rewrite” in the rule action and select the SpaceMap in the "rewrite map" field and click "Ok"

9) Enter your url : http://hostname/ / and it will redirect to the pagefrom step 6

1
  • It not works for case http://hostname/ /blablabla Jan 30 '18 at 15:50
3

This really an IIS issue. The solution is to update the httpErrors under the system.webServer like below:

<httpErrors errorMode="Custom" existingResponse="Replace"> <remove statusCode="400" subStatusCode="-1" /> <remove statusCode="404" subStatusCode="-1" /> <remove statusCode="500" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/error" responseMode="ExecuteURL" /> <error statusCode="400" prefixLanguageFilePath="" path="/error" responseMode="ExecuteURL" /> <error statusCode="500" prefixLanguageFilePath="" path="/error" responseMode="ExecuteURL" /> </httpErrors>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.