Troubleshooting ASP.NET5 Website in IIS

 

 

 

Recently I have published this blog, which talks about configuring the ASP.NET 5 application in IIS.

After you set this up, if you run into any issues while accessing the website you can enable the inbuilt logging provided within the HTTPPlatform Handler.

 

 

 

How to enable the logging ?

 

· Open the Configuration Editor at the website level.

clip_image002[4]

 

· Set the field stdoutLogEnabled to True as shown below:

 

clip_image004[4]

 

 

· After the above setting is enabled, the logs will be saved under stdoutLogFile. The default location is: \logs\stdout.log. You can change the path and modify the path accordingly.

 

Scenario:  

 

Recently I worked with one of the customer who was running into the below exception in the stdout.log file while accessing his website:

 

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The filename or extension is too long.

File name: 'Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' ---> System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

   at System.IO.PathHelper.GetFullPathName()

   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.Reflection.Assembly.LoadFile(String path)

   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath)

   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)

   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName)

  at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)

   at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)

   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)

  at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)

   at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)

   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

   at Microsoft.AspNet.Hosting.WebApplication.Run(Type startupType, String[] args)

   at Microsoft.AspNet.Server.Kestrel.Program.Main(String[] args)

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)

   at Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0()

   at System.Threading.Tasks.Task`1.InnerInvoke()

   at System.Threading.Tasks.Task.Execute()

 

 

System.IO.PathTooLongException:The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

   at System.IO.PathHelper.GetFullPathName()

   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.Reflection.Assembly.LoadFile(String path)

   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath)

   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)

   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName)

   at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)

   at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)

   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)

   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)

   at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)

   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

 

 

 

 

Solution :

 

 

We had to place the wwwroot and the approot to a different location so that the path doesn’t include more than 248 characters.