Illegal Characters in Path Sitecore
Instead of redirecting to the "Item Not Found" page, Sitecore may generate the following error messages when it receives a request containing Illegal characters in the path:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR Application error. | |
Exception: System.ArgumentException | |
Message: Illegal characters in path. | |
Source: mscorlib | |
at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths) | |
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) | |
at System.IO.Path.GetFullPathInternal(String path) | |
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) | |
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) | |
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) | |
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) | |
at System.Web.InternalSecurityPermissions.PathDiscovery(String path) | |
at System.Web.HttpRequest.get_PhysicalPath() | |
at Sitecore.Web.XFrameOptionsHeaderModule.IsSitecoreFolderRequest(HttpContextBase httpContext) | |
at Sitecore.Web.XFrameOptionsHeaderModule.BeginRequestHandler(Object sender, EventArgs e) | |
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() | |
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) | |
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) |
Solution:
I saw a similar issue and it could depend on the "requestPathInvalidCharacters" settings in <httpRuntime> in Web.config.
- Go to the web.config and search for httpRuntime node.
- Check if the requestValidationMode is there, if it is not then add the attribute requestValidationMode="2.0"
-
Make sure validateRequest attribute in the page node is set to
false.
<pages validateRequest="false"> -
If you want to add these characters to the path, add the
requestPathInvalidCharacters attribute to the
httpRuntime node.
<httpRuntime targetFramework="4.8" ...... requestPathInvalidCharacters="<,>,*,%,&,:,\,?"/>
Reference:
Happy Sitecoreing 😊
Comments
Post a Comment