当前位置: 首页>>代码示例>>C#>>正文


C# IAppBuilder.UseErrorPage方法代码示例

本文整理汇总了C#中IAppBuilder.UseErrorPage方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseErrorPage方法的具体用法?C# IAppBuilder.UseErrorPage怎么用?C# IAppBuilder.UseErrorPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAppBuilder的用法示例。


在下文中一共展示了IAppBuilder.UseErrorPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configuration

        public void Configuration(IAppBuilder app)
        {
            var configuration = new JabbrConfiguration();

            if (configuration.MigrateDatabase)
            {
                // Perform the required migrations
                DoMigrations();
            }

            var kernel = SetupNinject(configuration);

            app.Use(typeof(DetectSchemeHandler));

            if (configuration.RequireHttps)
            {
                app.Use(typeof(RequireHttpsHandler));
            }

            app.UseErrorPage();

            SetupAuth(app, kernel);
            SetupSignalR(kernel, app);
            SetupWebApi(kernel, app);
            SetupMiddleware(kernel, app);
            SetupNancy(kernel, app);

            SetupErrorHandling();
        }
开发者ID:sachin303,项目名称:JabbR,代码行数:29,代码来源:Startup.cs

示例2: ModuleAndHandlerSyncException

        public void ModuleAndHandlerSyncException(IAppBuilder app)
        {
            app.UseErrorPage();
            app.Use(async (context, next) =>
            {
                // Expect async exception from the handler.
                try
                {
                    await next();
                    Assert.True(false, "Handler exception expected");
                }
                catch (NotFiniteNumberException)
                {
                }
            });

            RouteTable.Routes.MapOwinPath("/", app2 =>
            {
                app2.Run(context2 =>
                {
                    // Sync exception should become async before module sees it.
                    throw new NotFiniteNumberException("Handler exception");
                });
            });
        }
开发者ID:ricardodemauro,项目名称:katana-clone,代码行数:25,代码来源:SystemWebIntegrationTests.cs

示例3: Configuration

        public void Configuration(IAppBuilder app)
        {
            // Show an error page
            app.UseErrorPage();

            // Logging component
            app.Use<LoggingComponent>();

            // Configure web api routing
            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            // Use web api middleware
            app.UseWebApi(config);

            // Throw an exception
            app.Use(async (context, next) =>
            {
                if (context.Request.Path.ToString() == "/fail")
                    throw new Exception("Doh!");
                await next();
            });

            // Welcome page
            app.UseWelcomePage("/");
        }
开发者ID:jiantaow,项目名称:AdvDotNet.Samples,代码行数:31,代码来源:Startup.cs

示例4: Configuration

        public void Configuration(IAppBuilder app)
        {
            var relativePath = string.Format(@"..{0}..{0}", Path.DirectorySeparatorChar);
            var contentPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), relativePath);

            app.UseErrorPage();

            app.Use(async (ctx, next) =>
            {
                await next();
                Console.WriteLine($"{DateTime.Now.ToLongTimeString()}: {ctx.Request.Method} {ctx.Request.Uri.AbsolutePath}: {ctx.Response.StatusCode} {ctx.Response.ReasonPhrase}");
            });

            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(Path.Combine(contentPath, @"wwwroot")),
                EnableDirectoryBrowsing = false
            });

            var config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseWebApi(config);
        }
开发者ID:michaldudak,项目名称:dotnet-on-docker,代码行数:29,代码来源:Startup.cs

示例5: Configuration

        public void Configuration(IAppBuilder app)
        {
            var url = "http://" + WebRole.GetIP("Consul.SerfLan").ToString() + ":" + WebRole.GetPort("Consul.Http").ToString();

            app.UseErrorPage(ErrorPageOptions.ShowAll);
            app.UseConsulate(new Uri(url));
        }
开发者ID:jango2015,项目名称:Consulate,代码行数:7,代码来源:Startup.cs

示例6: Configuration

        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            // Remap '/' to '.\defaults\'.
            // Turns on static files and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(@".\defaults"),
            });

            // Only serve files requested by name.
            app.UseStaticFiles("/files");

            // Turns on static files, directory browsing, and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = new PathString("/public"),
                EnableDirectoryBrowsing = true,
            });

            // Browse the root of your application (but do not serve the files).
            // NOTE: Avoid serving static files from the root of your application or bin folder,
            // it allows people to download your application binaries, config files, etc..
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/src"),
                FileSystem = new PhysicalFileSystem(@""),
            });

            // Anything not handled will land at the welcome page.
            app.UseWelcomePage();
        }
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:35,代码来源:Startup.cs

示例7: Configuration

        public void Configuration(IAppBuilder app)
        {
            // So that squishit works
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.SetupInformation.ApplicationBase);

            var configuration = new JabbrConfiguration();

            if (configuration.MigrateDatabase)
            {
                // Perform the required migrations
                DoMigrations();
            }

            var kernel = SetupNinject(configuration);

            app.Use(typeof(DetectSchemeHandler));

            if (configuration.RequireHttps)
            {
                app.Use(typeof(RequireHttpsHandler));
            }

            app.UseErrorPage();

            SetupAuth(app, kernel);
            SetupSignalR(configuration, kernel, app);
            SetupWebApi(kernel, app);
            SetupMiddleware(kernel, app);
            SetupFileUpload(kernel, app);
            SetupNancy(kernel, app);

            SetupErrorHandling();
        }
开发者ID:Virgil-Imbrea,项目名称:fixitnao,代码行数:33,代码来源:Startup.cs

示例8: KnownStagesSpecified

 public void KnownStagesSpecified(IAppBuilder app)
 {
     app.UseErrorPage();
     app.Use<BreadCrumbMiddleware>("a", "Authenticate");
     AddStageMarker(app, "Authenticate");
     app.Use<BreadCrumbMiddleware>("b", "PostAuthenticate");
     AddStageMarker(app, "PostAuthenticate");
     app.Use<BreadCrumbMiddleware>("c", "Authorize");
     AddStageMarker(app, "Authorize");
     app.Use<BreadCrumbMiddleware>("d", "PostAuthorize");
     AddStageMarker(app, "PostAuthorize");
     app.Use<BreadCrumbMiddleware>("e", "ResolveCache");
     AddStageMarker(app, "ResolveCache");
     app.Use<BreadCrumbMiddleware>("f", "PostResolveCache");
     AddStageMarker(app, "PostResolveCache");
     app.Use<BreadCrumbMiddleware>("g", "MapHandler");
     AddStageMarker(app, "MapHandler");
     app.Use<BreadCrumbMiddleware>("h", "PostMapHandler");
     AddStageMarker(app, "PostMapHandler");
     app.Use<BreadCrumbMiddleware>("i", "AcquireState");
     AddStageMarker(app, "AcquireState");
     app.Use<BreadCrumbMiddleware>("j", "PostAcquireState");
     AddStageMarker(app, "PostAcquireState");
     app.Use<BreadCrumbMiddleware>("k", "PreHandlerExecute");
     AddStageMarker(app, "PreHandlerExecute");
     app.Run(context =>
     {
         var fullBreadCrumb = context.Get<string>("test.BreadCrumb");
         Assert.Equal("abcdefghijk", fullBreadCrumb);
         return Task.FromResult(0);
     });
 }
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:32,代码来源:IntegratedPipelineTests.cs

示例9: Configuration

        public void Configuration(IAppBuilder app)
        {
            /* // Note: Enable only for debugging. This slows down the perf tests.
            app.Use((context, next) =>
            {
                var req = context.Request;
                context.TraceOutput.WriteLine("{0} {1}{2} {3}", req.Method, req.PathBase, req.Path, req.QueryString);
                return next();
            });*/

            app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 20 });
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.Use<CanonicalRequestPatterns>();

            app.UseStaticFiles(new StaticFileOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseStageMarker(PipelineStage.MapHandler);

            FileServerOptions options = new FileServerOptions();
            options.EnableDirectoryBrowsing = true;
            options.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseWelcomePage("/Welcome");
        }
开发者ID:Xamarui,项目名称:Katana,代码行数:33,代码来源:Startup.cs

示例10: ExpectedKeys

        public void ExpectedKeys(IAppBuilder app)
        {
            app.UseErrorPage();
            app.Use((context, next) =>
            {
                var env = context.Environment;
                object ignored;
                Assert.True(env.TryGetValue("owin.RequestMethod", out ignored));
                Assert.Equal("GET", env["owin.RequestMethod"]);

                Assert.True(env.TryGetValue("owin.RequestPath", out ignored));
                Assert.Equal("/", env["owin.RequestPath"]);

                Assert.True(env.TryGetValue("owin.RequestPathBase", out ignored));
                Assert.Equal(string.Empty, env["owin.RequestPathBase"]);

                Assert.True(env.TryGetValue("owin.RequestProtocol", out ignored));
                Assert.Equal("HTTP/1.1", env["owin.RequestProtocol"]);

                Assert.True(env.TryGetValue("owin.RequestQueryString", out ignored));
                Assert.Equal(string.Empty, env["owin.RequestQueryString"]);

                Assert.True(env.TryGetValue("owin.RequestScheme", out ignored));
                Assert.Equal("http", env["owin.RequestScheme"]);

                Assert.True(env.TryGetValue("owin.Version", out ignored));
                Assert.Equal("1.0", env["owin.Version"]);

                Assert.True(env.TryGetValue("owin.RequestId", out ignored));
                Assert.False(string.IsNullOrWhiteSpace((string)env["owin.RequestId"]));

                return Task.FromResult(0);
            });
        }
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:34,代码来源:SystemWebIntegrationTests.cs

示例11: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage();

            // Temporary bridge from katana to Owin
            app.UseBuilder(ConfigurePK);
        }
开发者ID:jizhonglee,项目名称:StaticFiles,代码行数:7,代码来源:Startup.cs

示例12: Configuration

        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            app.UseWelcomePage("/");
        }
开发者ID:tkggand,项目名称:katana,代码行数:7,代码来源:Startup.cs

示例13: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage();

            app.Map("/raw-connection", map =>
            {
                // Turns cors support on allowing everything
                // In real applications, the origins should be locked down
                map.UseCors(CorsOptions.AllowAll)
                   .RunSignalR<RawConnection>();
            });

            app.Map("/signalr", map =>
            {
                var config = new HubConfiguration
                {
                    // You can enable JSONP by uncommenting this line
                    // JSONP requests are insecure but some older browsers (and some
                    // versions of IE) require JSONP to work cross domain
                    // EnableJSONP = true
                };

                // Turns cors support on allowing everything
                // In real applications, the origins should be locked down
                map.UseCors(CorsOptions.AllowAll)
                   .RunSignalR(config);
            });

            // Turn tracing on programmatically
            GlobalHost.TraceManager.Switch.Level = SourceLevels.All;
        }
开发者ID:batrashish,项目名称:signalr-qt,代码行数:31,代码来源:Startup.cs

示例14: Configuration

        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            //when things go south
            app.UseErrorPage();
            #endif

            FileServerOptions fileServerOptions = new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(@".\\public"),
            };

            //In order to serve json files
            fileServerOptions.StaticFileOptions.ServeUnknownFileTypes = true;
            fileServerOptions.StaticFileOptions.DefaultContentType = "text";

            // Remap '/' to '.\public\'.
            // Turns on static files and public files.
            app.UseFileServer(fileServerOptions);

            app.UseStageMarker(PipelineStage.MapHandler);

            //Web Api
            HttpConfiguration config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();

            //Cause all the cool kids use JSON
            config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            app.UseWebApi(config);
        }
开发者ID:nojaf,项目名称:OwinChristmasPresents,代码行数:33,代码来源:Startup.cs

示例15: Configuration

        public void Configuration(IAppBuilder app)
        {
            var appOptions = new FileServerOptions
            {
                RequestPath = new PathString("/app"),
                FileSystem = new PhysicalFileSystem("app"),
                EnableDefaultFiles = true
            };
            appOptions.DefaultFilesOptions.DefaultFileNames.Add("index.html");
            appOptions.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseFileServer(appOptions);

            var libsOptions = new FileServerOptions
            {
                RequestPath = new PathString("/libs"),
                FileSystem = new PhysicalFileSystem("libs")
            };
            libsOptions.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseFileServer(libsOptions);

            app.UseErrorPage();
            app.MapSignalR();
        }
开发者ID:Wolfium,项目名称:AngularJSSignalRDashboard,代码行数:25,代码来源:Startup.cs


注:本文中的IAppBuilder.UseErrorPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。