/// <summary> /// Handles GET and HEAD request. /// </summary> /// <param name="context">Instace of <see cref="DavContextBaseAsync"/>.</param> /// <param name="item">Instance of <see cref="IHierarchyItemAsync"/> which was returned by /// <see cref="DavContextBaseAsync.GetHierarchyItemAsync"/> for this request.</param> public async Task ProcessRequestAsync(DavContextBaseAsync context, IHierarchyItemAsync item) { string urlPath = context.Request.RawUrl.Substring(context.Request.ApplicationPath.TrimEnd('/').Length); if (item is IItemCollectionAsync) { // In case of GET requests to WebDAV folders we serve a web page to display // any information about this server and how to use it. // Remember to call EnsureBeforeResponseWasCalledAsync here if your context implementation // makes some useful things in BeforeResponseAsync. await context.EnsureBeforeResponseWasCalledAsync(); IHttpAsyncHandler page = (IHttpAsyncHandler)System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath( "~/MyCustomHandlerPage.aspx", typeof(MyCustomHandlerPage)); if (Type.GetType("Mono.Runtime") != null) { page.ProcessRequest(HttpContext.Current); } else { // Here we call BeginProcessRequest instead of ProcessRequest to start an async page execution and be able to call RegisterAsyncTask if required. // To call APM method (Begin/End) from TAP method (Task/async/await) the Task.FromAsync must be used. await Task.Factory.FromAsync(page.BeginProcessRequest, page.EndProcessRequest, HttpContext.Current, null); } } else { await OriginalHandler.ProcessRequestAsync(context, item); } }
/// <summary> /// Handles GET and HEAD request. /// </summary> /// <param name="context">Instace of <see cref="DavContextBaseAsync"/>.</param> /// <param name="item">Instance of <see cref="IHierarchyItemAsync"/> which was returned by /// <see cref="DavContextBaseAsync.GetHierarchyItemAsync"/> for this request.</param> public void ProcessRequest(DavContextBase context, IHierarchyItem item) { if (item is IItemCollection) { // In case of GET requests to WebDAV folders we serve a web page to display // any information about this server and how to use it. // Remember to call EnsureBeforeResponseWasCalled here if your context implementation // makes some useful things in BeforeResponseAsync. context.EnsureBeforeResponseWasCalled(); IHttpAsyncHandler page = (IHttpAsyncHandler)System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath( "~/MyCustomHandlerPage.aspx", typeof(MyCustomHandlerPage)); page.ProcessRequest(HttpContext.Current); } else { OriginalHandler.ProcessRequest(context, item); } }
public void ProcessRequest(HttpContext context) { _originalHandler.ProcessRequest(context); }