How to fix System.IO.DirectoryNotFoundException in Windows Server IIS-10 when using Network Path in Owin.FileSystems PhysicalFileSystem

0

I have a .NET Framework 4.5 Website using Microsoft.Owin PhysicalFileSytem. In my workstation the website is running smoothly when hosting to IIS but when deploying to Windows Server IIS it throws a DirectoryNotFoundException. I'm using a shared folder as my network path in PhysicalFileSystem.

In the Windows Server I have already set the ApplicationPool Identity to Administrator account and set the Website Connect As to Administrator account

var fileSystem = new PhysicalFileSystem("\\10.12.50.40\Contents\");
                var options = new FileServerOptions
                {
                    FileSystem = fileSystem,
                    EnableDirectoryBrowsing = false,
                    RequestPath = "/InSysStorage/WebContent"
                };
app.UseFileServer(options);

Exception:

Server Error in '/InSysReport' Application. \10.12.50.40\Contents\ 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.IO.DirectoryNotFoundException: \10.12.50.40\Contents\

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:

[DirectoryNotFoundException: \10.12.50.40\Contents]
Microsoft.Owin.FileSystems.PhysicalFileSystem..ctor(String root) +74
InSys.Report.Startup.Configuration(IAppBuilder app) in D:\TEAM PROJECTS\InSys.HRMS\Development\Solution\Web\InSys.Report\Startup.cs:29

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +150
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101 Owin.Loader.<>c__DisplayClass18_1.b__0(IAppBuilder builder) +66
Owin.Loader.<>c__DisplayClass9_0.b__0(IAppBuilder builder) +123
Microsoft.Owin.Host.SystemWeb.<>c__DisplayClass5_0.b__0(IAppBuilder builder) +81
Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action`1 startup) +462
Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action`1 startup) +40 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +70 System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +536
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10043408 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

c#
owin
ioexception
unc
iis-10
asked on Stack Overflow Aug 14, 2019 by Rossu Belmonte • edited Aug 14, 2019 by BACON

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0