November Happy Hour will be moved to Thursday December 5th.

Illegal characters in path rendering XHtmlString

Vote:
 

We get a lot of logs looking like this

System.ArgumentException: Illegal characters in path.
   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.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext)
   at System.Web.Mvc.ViewUserControl.RenderViewAndRestoreContentType(ViewPage containerPage, ViewContext viewContext)
   at System.Web.Mvc.ViewUserControl.RenderView(ViewContext viewContext)
   at System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, String templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames, GetDefaultActionsDelegate getDefaultActions)
   at System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData, ExecuteTemplateDelegate executeTemplate)
   at System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData)
   at System.Web.Mvc.Html.TemplateHelpers.TemplateFor[TContainer,TValue](HtmlHelper`1 html, Expression`1 expression, String templateName, String htmlFieldName, DataBoundControlMode mode, Object additionalViewData)
   at System.Web.Mvc.Html.DisplayExtensions.DisplayFor[TModel,TValue](HtmlHelper`1 html, Expression`1 expression)
   at EPiServer.Web.Mvc.Html.PropertyRenderer.<>c__DisplayClass12_0`2.<GetHtmlForDefaultMode>b__0(StringWriter writer)
   at EPiServer.Web.Mvc.Html.PropertyRenderer.CreateMvcHtmlString(Action`1 action)
   at EPiServer.Web.Mvc.Html.PropertyRenderer.PropertyFor[TModel,TValue](HtmlHelper`1 html, String viewModelPropertyName, Object additionalViewData, Object editorSettings, Expression`1 expression, Func`2 displayForAction)
   at EPiServer.Web.Mvc.Html.PropertyExtensions.PropertyFor[TModel,TValue](HtmlHelper`1 html, Expression`1 expression)
   at ASP._Page_Features_VehiclePage_PartialViews_DynamicBlocks__PremiumWarrantyBlock_cshtml.Execute()

The XhtmlString property has nothing special, just text and it's added to the ViewModel in the following way, reading a specific blocktypwe from a contentarea and checks if specified values match the current vehicle values. If so the viewmodel property gets set.

var premiumWarrantyBlocks = currentPage.PremiumWarranties?.FilteredItems.AsNotNull().Select(p => p.GetContent() as PremiumWarrantyBlock).ToList();

            foreach (var premiumWarrantyBlock in premiumWarrantyBlocks.AsNotNull())
            {
                if (VehicleHelper.IsPremiumSelection(premiumWarrantyBlock.MatchValues?.ToList(), vehicle))
                {
                    vehicleViewModel.PremiumWarrantyBlock = premiumWarrantyBlock;
                    break;
                }

                if (!premiumWarrantyBlock.MatchValues.AsNotNull().Any(matchValue =>
                    vehicleDescription.Contains(matchValue, StringComparison.OrdinalIgnoreCase))) continue;
                vehicleViewModel.PremiumWarrantyBlock = premiumWarrantyBlock;
                break;
            }

And rendered frontend using

@Html.PropertyFor(m => m.MainContent)

I have no clue to what causes this and loading the pages where this is used is working properly so I can't really debug it either.

#245564
Edited, Dec 15, 2020 11:12
Vote:
 

If you provide some text that can reproduce the illegal characters in path rendering it might be easier to help you out.

#245935
Dec 22, 2020 6:25
Vote:
 

Hi,

Is there any specific language you are getting this error or it's common for all?

If it is specific for any particular language then try to find and remove the special character from the name of any page/block.

#245938
Dec 22, 2020 6:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.