コード例 #1
0
        public void Configure(IApplicationBuilder builder, IConfiguration configuration)
        {
            builder.UseMultipleErrorHandlerPipelines(app =>
            {
                MapExtensions.Map(
                    app,
                    "/throws",
                    inner =>
                    RunExtensions.Run(
                        inner,
                        async ctx =>
                {
                    await Task.Yield();
                    throw new Exception("Map exception");
                }));

                MvcApplicationBuilderExtensions.UseMvc(
                    app,
                    routes =>
                {
                    MapRouteRouteBuilderExtensions.MapRoute(routes, "custom", "Test/{action=Index}", new { Controller = "MyTest" });
                    MapRouteRouteBuilderExtensions.MapRoute(routes, "default", "{controller=Home}/{action=Index}/{id?}");
                });
            });
        }
コード例 #2
0
        /// <summary>
        /// Adds ChatApp Middleware to http pipeline and maps it to the specified path
        /// </summary>
        /// <returns></returns>
        public static IApplicationBuilder UseChatApp(this IApplicationBuilder app, string MapPath = "/ChatApp", string HubEndPoint = "/ChatHub")
        {
            if (!string.IsNullOrWhiteSpace(MapPath))
            {
                RouteCustomizer.Prefix = MapPath;
                MapPath = MapPath.StartsWith("/") ? MapPath : "/" + MapPath;
            }
            else
            {
                MapPath = "/ChatApp";
            }
            if (!string.IsNullOrWhiteSpace(HubEndPoint))
            {
                HubEndPoint = HubEndPoint.StartsWith("/") ? HubEndPoint : "/" + HubEndPoint;
            }
            else
            {
                HubEndPoint = "/ChatHub";
            }
            app.MapWhen(context => context.Request.Path.StartsWithSegments(MapPath),
                        _app =>
            {
                _app.UseSignalR(h => h.MapHub <ChatCoreHub>(MapPath + HubEndPoint));
                MvcApplicationBuilderExtensions.UseMvc(app);
            });

            return(app);
        }
コード例 #3
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     if (HostingEnvironmentExtensions.IsDevelopment(env))
     {
         DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app);
     }
     else
     {
         HstsBuilderExtensions.UseHsts(app);
     }
     MvcApplicationBuilderExtensions.UseMvc(app);
 }
コード例 #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseStatusCodePages();
            app.UseAuthentication();


            if (HostingEnvironmentExtensions.IsDevelopment(env))
            {
                DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app);
            }
            MvcApplicationBuilderExtensions.UseMvc(app);
        }
コード例 #5
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     if (HostingEnvironmentExtensions.IsDevelopment(env))
     {
         DeveloperExceptionPageExtensions.UseDeveloperExceptionPage(app);
     }
     else
     {
         ExceptionHandlerExtensions.UseExceptionHandler(app, "/Error");
         HstsBuilderExtensions.UseHsts(app);
     }
     HttpsPolicyBuilderExtensions.UseHttpsRedirection(app);
     StaticFileExtensions.UseStaticFiles(app);
     MvcApplicationBuilderExtensions.UseMvc(app);
 }