/// <summary> /// Process an individual request. /// </summary> public async Task Invoke(HttpContext context) { if (Interlocked.Exchange(ref configurationSaved, 1) == 0) { VisualStudioHelper.DumpConfiguration(Configuration, Configuration.ApplicationPhysicalPath); } // create the context var dotvvmContext = CreateDotvvmContext(context); context.Items.Add(HostingConstants.DotvvmRequestContextOwinKey, dotvvmContext); var requestCultureFeature = context.Features.Get <IRequestCultureFeature>(); if (requestCultureFeature == null) { dotvvmContext.ChangeCurrentCulture(Configuration.DefaultCulture); } foreach (var middleware in middlewares) { if (await middleware.Handle(dotvvmContext)) { return; } } await next(context); }
/// <summary> /// Process an individual request. /// </summary> public override async Task Invoke(IOwinContext context) { if (Interlocked.Exchange(ref configurationSaved, 1) == 0) { VisualStudioHelper.DumpConfiguration(Configuration, Configuration.ApplicationPhysicalPath); } using (var scope = Configuration.ServiceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope()) { // create the context var dotvvmContext = CreateDotvvmContext(context, scope); dotvvmContext.Services.GetRequiredService <DotvvmRequestContextStorage>().Context = dotvvmContext; context.Set(HostingConstants.DotvvmRequestContextOwinKey, dotvvmContext); dotvvmContext.ChangeCurrentCulture(Configuration.DefaultCulture); try { foreach (var middleware in middlewares) { if (await middleware.Handle(dotvvmContext)) { return; } } } catch (DotvvmInterruptRequestExecutionException) { return; } // we cannot handle the request, pass it to another component await Next.Invoke(context); } }
/// <summary> /// Process an individual request. /// </summary> public async Task Invoke(HttpContext context) { if (Interlocked.Exchange(ref configurationSaved, 1) == 0) { VisualStudioHelper.DumpConfiguration(Configuration, Configuration.ApplicationPhysicalPath); } // create the context var dotvvmContext = CreateDotvvmContext(context); context.RequestServices.GetService <DotvvmRequestContextStorage>().Context = dotvvmContext; context.Items[HostingConstants.DotvvmRequestContextOwinKey] = dotvvmContext; var requestCultureFeature = context.Features.Get <IRequestCultureFeature>(); if (requestCultureFeature == null) { dotvvmContext.ChangeCurrentCulture(Configuration.DefaultCulture); } try { foreach (var middleware in middlewares) { if (await middleware.Handle(dotvvmContext)) { return; } } } catch (DotvvmInterruptRequestExecutionException) { return; } await next(context); }
/// <summary> /// Process an individual request. /// </summary> public override async Task Invoke(IOwinContext context) { if (Interlocked.Exchange(ref configurationSaved, 1) == 0) { VisualStudioHelper.DumpConfiguration(Configuration, Configuration.ApplicationPhysicalPath); } // create the context var dotvvmContext = new DotvvmRequestContext() { OwinContext = context, Configuration = Configuration, ResourceManager = new ResourceManager(Configuration), ViewModelSerializer = Configuration.ServiceLocator.GetService <IViewModelSerializer>() }; context.Set(HostingConstants.DotvvmRequestContextOwinKey, dotvvmContext); // attempt to translate Googlebot hashbang espaced fragment URL to a plain URL string. string url; if (!TryParseGooglebotHashbangEscapedFragment(context.Request.QueryString, out url)) { url = context.Request.Path.Value; } url = url.Trim('/'); // find the route IDictionary <string, object> parameters = null; var route = Configuration.RouteTable.FirstOrDefault(r => r.IsMatch(url, out parameters)); if (route != null) { // handle the request dotvvmContext.Route = route; dotvvmContext.Parameters = parameters; dotvvmContext.Query = context.Request.Query .ToDictionary(d => d.Key, d => d.Value.Length == 1 ? (object)d.Value[0] : d.Value); try { await route.ProcessRequest(dotvvmContext); return; } catch (DotvvmInterruptRequestExecutionException) { // the response has already been generated, do nothing return; } } // we cannot handle the request, pass it to another component await Next.Invoke(context); }
/// <summary> /// Process an individual request. /// </summary> public override async Task Invoke(IOwinContext context) { if (Interlocked.Exchange(ref configurationSaved, 1) == 0) { VisualStudioHelper.DumpConfiguration(Configuration, Configuration.ApplicationPhysicalPath); } // create the context var dotvvmContext = CreateDotvvmContext(context); context.Set(HostingConstants.DotvvmRequestContextOwinKey, dotvvmContext); dotvvmContext.ChangeCurrentCulture(Configuration.DefaultCulture); foreach (var middleware in middlewares) { if (await middleware.Handle(dotvvmContext)) { return; } } // we cannot handle the request, pass it to another component await Next.Invoke(context); }