ramondeklein/nwebdav

How to deploy on IIS

tdhintz opened this issue · 11 comments

Would you provide basic instructions for deploying on IIS?

Better take look at Kester sample because with AspNetHandler sample I have troubles with LibreOffice who send LOCK request twice. With HttpListener or Kester everything seems ok dont know why.
How host net core app on IIS you can read there https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?tabs=aspnetcore2x

Could not load type 'NWebDav.Sample.AspNet.DiskWebDavHandlerFactory'.

[HttpException (0x80004005): Could not load type 'NWebDav.Sample.AspNet.DiskWebDavHandlerFactory'.]
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +12510809
System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type) +47
System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +18
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +27
System.Web.HttpApplication.GetFactory(String type) +94
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +375
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

@pizixie What steps did you take to deploy the AspNet sample?

@tdhintz
copy the 'bin' dir to the website dir
copy the 'web.config' to the website dir
start the website and view in browse

Here is what I've tried.

  1. Enable the IIS feature in Windows Server 2016.
  2. Using IIS Manager, create both a Virtual Directory called NWebDav, and an Application called WebDav.
  3. Remove the default files from C:\inetpub\wwwroot.
  4. Copy ...\NWebDav.Sample.AspNet\web.config to each of the folders C:\inetpub\wwwroot\NWebDav and C:\inetpub\wwwroot\WebDav.
  5. Copy ...\NWebDav.Sample.AspNet\bin* to bin folders under each of the folders C:\inetpub\wwwroot\NWebDav and C:\inetpub\wwwroot\WebDav.
  6. Note, authentication is anonymous by default. Verified .Net 4.5.2 was installed (.net 4.5 is targeted by the build).
  7. Open a browser and use each of the following URLs

The URLs respond with:

HTTP Error 404.0 - Not Found

Detailed Error Information:

Module | ManagedPipelineHandler  Requested URL | https://localhost:443/nwebdav
Notification | ExecuteRequestHandler  Physical Path | C:\inetpub\wwwroot\nwebdav
Handler | WebDavHandlerFactory  Logon Method | Anonymous
Error Code | 0x00000000  Logon User | Anonymous

Added Log4Net assemblies to the bin folder and updated the web.config for logging, but the log isn't updated.

I know it sounds thick, but I'm missing something basic.

it's success when i debug in vs.
but failed that deploy on windows server 2008 .
i'll try you way.

thank you @tdhintz

NWebDav.Sample.AspNet run on iis express but when run on IIS. Run office word but wait on load screen .
Thanks for the guidance

I have the same issue.
I have in IIS installed WebDAV Publishing component. After removing this component NWebDav now working on my ASP.NET Core 2.1 application published to IIS.
More info about this is here http://docs.simplifier.net/vonk/deployment/reverseProxy/iis.html

NWebDav.Sample.AspNet run on iis express or IIS with localhost(http://localhost/webdav). but when Run with localhost ip address(http://10.10.20.100/webdav).office word wait on load screen .
also in localhost send 4 request(options,head,Options,get) but on Ip address Only send 2 request (Options,Head)
Thanks for the guidance

Here are a few pointers I've learned.

  1. DEVExplorer is a nice client tool in Java that can provide tracing. See DAVExplorer.org.
  2. Installed IIS 10 on Server 2016 clean and turned on just about all of its features.
  3. Change code as noted below and build NWebDav.Sample.AspNet.
  4. Make a folder C:\inetpub\wwwroot\MyDav\bin and copy ...\NWebDav.Sample.AspNet\bin contents there.
  5. Add a web.config to C:\inetpub\wwwroot\MyDav (see below).
  6. In IIS Manager add an Application called MyDav under Default Web Site, turn on Basic Authentication, turn off Compression.
  7. Change the Application Pools | DefaultAppPool | Advanced Settings | Identity to the credentials of a user with rights to the logging folder.
  8. Create the file C:\Temp\text.log to receive the log contents (see web.config).
  9. Run DAVExplorer and set the URL to "MyDav/filename".

This doesn't really work for me but the logging gives something to address.

Code change:

For debugging I replaced the following code...

var homeFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
return new WebDavDispatcher(new DiskStore(homeFolder), requestHandlerFactory);

With this code...
return new WebDavDispatcher(new DiskStore(@"C:\inetpub\wwwroot"), requestHandlerFactory);

web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <handlers>
	<remove name="MyDav" />
        <add name="MyDav" verb="*" path="*" type="NWebDav.Sample.AspNet.DiskWebDavHandlerFactory" preCondition="integratedMode" modules="ManagedPipelineHandler" />
    </handlers>
        <urlCompression doStaticCompression="false" doDynamicCompression="false" />
</system.webServer>
  <system.diagnostics>
    <trace autoflush="true" indentsize="7">
      <listeners>  
        <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\temp\Text.log" />  
        <remove name="Default" />  
      </listeners> 
	</trace>
  </system.diagnostics>
</configuration>