【发布时间】:2015-08-07 15:50:18
【问题描述】:
概述:
- 在 web.config 中配置了 404 错误页面并且可以正常工作
- 使用 Umbraco v6.2
- customErrors 设置为
RemoteOnly
问题是当我在 URL 中输入“%7C”时,我收到了这个:
Illegal characters in path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Illegal characters in path.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Illegal characters in path.]
System.IO.Path.GetExtension(String path) +14365864
Umbraco.Core.UriExtensions.IsClientSideRequest(Uri url) +23
Umbraco.Web.UmbracoModule.BeginRequest(HttpContextBase httpContext) +365
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
%7C 是一个管道“|”。 %7C 是唯一一个(我试过的)给我 YSOD 的。
如果我放了任何东西(我已经尝试了 30 多种组合),例如 %7A、%2A,那么有时它会给我这个错误而没有进入 404 页面,但绝不会出现 YSOD:
Bad Request - Invalid URL
HTTP Error 400. The request URL is invalid.
web.config
<customErrors mode="RemoteOnly" defaultRedirect="~/error-page" />
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="503" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="~/error-page" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="~/error-page" responseMode="ExecuteURL" />
<error statusCode="503" prefixLanguageFilePath="" path="~/error-page" responseMode="ExecuteURL" />
</httpErrors>
在 Umbraco 中,有一个配置文件 (umbracoSettings.config),其中包含一个 XML 部分,其中包含字符替换。
例子:
<char org="~"></char>
<char org=" ">-</char>
<char org="""></char>
<char org="'"></char>
<char org="%"></char>
<char org="."></char>
<char org="|"></char>
你可以看到管道在那里。如果我输入网址,
local.website.com/asdf|(注意管道),它被编码为local.website.com/asdf%7C。
我尝试添加<char org="%7C"></char>,但它不起作用。我错过了什么吗?这是一个已知的错误吗?
【问题讨论】:
标签: c# error-handling web-config umbraco