/// <summary> /// Ensures the redirect required by the OWIN Security middleware is properly handled by DotVVM client library. /// </summary> public static void ApplyRedirectResponse(IOwinContext context, string redirectUri) { if (context.Response.StatusCode == (int)HttpStatusCode.Unauthorized) { DotvvmRequestContext.SetRedirectResponse(DotvvmMiddleware.ConvertHttpContext(context), redirectUri, (int)HttpStatusCode.Redirect, true); } }
public override Task Invoke(IOwinContext context) { var url = DotvvmMiddleware.GetCleanRequestUrl(context); if (url.StartsWith(Constants.GlobalizeCultureUrlPath, StringComparison.Ordinal)) { return(RenderResponse(context)); } else { return(Next.Invoke(context)); } }
public override Task Invoke(IOwinContext context) { var url = DotvvmMiddleware.GetCleanRequestUrl(context); // file upload handler if (url == Constants.FileUploadHandlerMatchUrl) { return(ProcessMultipartRequest(context)); } else { return(Next.Invoke(context)); } }
public override Task Invoke(IOwinContext context) { var url = DotvvmMiddleware.GetCleanRequestUrl(context); // file upload handler if (url == HostingConstants.FileUploadHandlerMatchUrl || url.StartsWith(HostingConstants.FileUploadHandlerMatchUrl + "?", StringComparison.OrdinalIgnoreCase)) { return(ProcessMultipartRequest(context)); } else { return(Next.Invoke(context)); } }
/// <summary> /// Translates the virtual path (~/something) to the domain relative path (/virtualDirectory/something). /// For example, when the app is configured to run in a virtual directory '/virtDir', the URL '~/myPage.dothtml' will be translated to '/virtDir/myPage.dothtml'. /// </summary> public static string TranslateVirtualPath(string virtualUrl, IOwinContext owinContext) { if (virtualUrl.StartsWith("~/", StringComparison.Ordinal)) { var url = DotvvmMiddleware.GetVirtualDirectory(owinContext) + "/" + virtualUrl.Substring(2); if (!url.StartsWith("/", StringComparison.Ordinal)) { url = "/" + url; } return(url); } else { return(virtualUrl); } }
public override async Task Invoke(IOwinContext context) { // try resolve the route var url = DotvvmMiddleware.GetCleanRequestUrl(context); // disable access to the dotvvm.json file if (url.StartsWith("dotvvm.json", StringComparison.CurrentCultureIgnoreCase)) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; throw new UnauthorizedAccessException("The dotvvm.json cannot be served!"); } else { await Next.Invoke(context); } }
public override Task Invoke(IOwinContext context) { // try resolve the route var url = DotvvmMiddleware.GetCleanRequestUrl(context); // disable access to the dotvvm.json file if (url.StartsWith("dotvvm.json", StringComparison.CurrentCultureIgnoreCase)) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; throw new UnauthorizedAccessException("The dotvvm.json cannot be served!"); } // embedded resource handler URL if (url.StartsWith(HostingConstants.ResourceHandlerMatchUrl, StringComparison.Ordinal)) { return(RenderEmbeddedResource(context)); } else { return(Next.Invoke(context)); } }
public override Task Invoke(IOwinContext context) { var url = DotvvmMiddleware.GetCleanRequestUrl(context); return(url.StartsWith("dotvvmReturnedFile", StringComparison.Ordinal) ? RenderReturnedFile(context) : Next.Invoke(context)); }
/// <summary> /// Ensures the redirect required by the ASP.NET Core Security middleware is properly handled by DotVVM client library. /// </summary> public static Task ApplyRedirectResponse(HttpContext context, string redirectUri) { DotvvmRequestContextExtensions.SetRedirectResponse(DotvvmRequestContext.GetCurrent(DotvvmMiddleware.ConvertHttpContext(context)), redirectUri, (int)HttpStatusCode.Redirect, allowSpaRedirect: false); throw new DotvvmInterruptRequestExecutionException(); }