Illegal characters in path on http request

36 Views Asked by At

I am currently working on migrating web application (C# .NetFramework 4.7.2) from Azure Cloud Services (Classic) to Virtual Machine Scale Set. Previously, I ran my app on cloud services instances with:

  1. Windows Server 2019 Version 1809
  2. IIS Version 10.0.17763.1

Then I am migrating to Virtual Machine Scale Set:

  1. Windows Server 2022 Version 21H2
  2. IIS version 10.0.20348.1

After migration, I deployed the same code/build in these two environments, but noticed difference in response when certain characters are included in the request.

Majority of my requests are CRUD on records in azure cosmos db.

For example, when I make a GET call to each VMSS and cloud service instance with url: https://www.azure.endpoint.com/my-resource-type/resource|name?query=something where my resource name contains '|' character, it returns 500 on new VMSS instance, but it returns 200 with my resource when Cloud service instance is used.

So far, I have discovered that <, >, and | characters differ in their responses. < and > were returning 400 on cloud services, but now return 500.

I am confused on why these two environments differ in their responses when deployed builds are exactly the same. More importantly, I would like to make Windows Server 2022 to work the same way it did for 2019 version in order to keep all old resources working as they used to.

Troubleshooting/logs: I have reviewed my logs and discovered that VMSS is throwing an exception Illegal characters in path, with following stack trace:

at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) at System.IO.Path.Combine(String path1, String path2) at System.Web.Compilation.DiskBuildResultCache.GetPreservedDataFileName(String cacheKey) at System.Web.Compilation.DiskBuildResultCache.GetBuildResult(String cacheKey, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.WebPages.BuildManagerWrapper.ExistsInPrecompiledSite(String virtualPath) at System.Web.WebPages.VirtualPathFactoryManager.Exists(String virtualPath) at System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func2 virtualPathExists) at System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func2 virtualPathExists, IDisplayMode currentDisplayMode, Boolean requireConsistentDisplayMode) at System.Web.WebPages.WebPageRoute.GetRouteLevelMatch(String pathValue, String[] supportedExtensions, Func2 virtualPathExists, HttpContextBase context, DisplayModeProvider displayModeProvider) at System.Web.WebPages.WebPageRoute.MatchRequest(String pathValue, String[] supportedExtensions, Func2 virtualPathExists, HttpContextBase context, DisplayModeProvider displayModes) at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.<>c__DisplayClass285_0.b__0() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Repair attempt: On stackoverflow, adding relaxedUrlToFileSystemMapping on Web.config's tag was mentioned, but adding this to my Web.config did not help resolving this issue:

0

There are 0 best solutions below