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


C# IAppBuilder.UseStageMarker方法代码示例

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


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

示例1: Configuration

        /// <summary>
        /// The Startup configuration sets up a pipeline with three middleware components, the first two displaying diagnostic information
        /// and the last one responding to events (and also displaying diagnostic information).  The PrintCurrentIntegratedPipelineStage 
        /// method displays the integrated pipeline event this middleware is invoked on and a message.
        /// </summary>
        public void Configuration(IAppBuilder app)
        {
            app.Use((context, next) =>
            {
                PrintCurrentIntegratedPipelineStage(context, "Middleware 1");
                return next.Invoke();
            });
            app.Use((context, next) =>
            {
                PrintCurrentIntegratedPipelineStage(context, "2nd MW");
                return next.Invoke();
            });
            // You can mark OMCs to execute at specific stages of the pipeline by using the IAppBuilder UseStageMarker() extension method.
            // To run a set of middleware components during a particular stage, insert a stage marker right after the last component is the set
            // during registration. There are rules on which stage of the pipeline you can execute middleware and the order components must run
            // (The rules are explained later in the tutorial). Add the UseStageMarker method to the Configuration code as shown below:
            app.UseStageMarker(PipelineStage.Authenticate);

            app.Run(context =>
            {
                PrintCurrentIntegratedPipelineStage(context, "3rd MW");
                return context.Response.WriteAsync("Hello world");
            });
            app.UseStageMarker(PipelineStage.ResolveCache);
        }
开发者ID:TheFastCat,项目名称:OWINKatanaExamples,代码行数:30,代码来源:Startup.cs

示例2: Start

        protected virtual void Start(IAppBuilder app, IContainer container)
        {
            var config = CreateHttpConfiguration();

            ConfigureWebApi(config, container);

            if (Settings.ShowExceptionDetails)
            {
                app.UseErrorPage(new ErrorPageOptions
                {
                    ShowExceptionDetails = true,
                    ShowSourceCode = true
                });
            }

            app.UseAutofacMiddleware(container);
            app.UseStageMarker(PipelineStage.Authenticate);

            app.UseAutofacWebApi(config);
            app.UseWebApi(config);
            RegisterSignalR(container, app);

            app.UseStageMarker(PipelineStage.MapHandler);

            RegisterServices(container, app, config);

            RegisterShutdown(app, container);

            StartIndexingIfConfigured(container);
        }
开发者ID:ompanda,项目名称:NuGet.Lucene,代码行数:30,代码来源:Startup.cs

示例3: Configuration

 /// <summary>
 /// OWIN start up method
 /// </summary>
 /// <param name="app">The app.</param>
 public void Configuration(IAppBuilder app)
 {
     var config = new System.Web.Http.HttpConfiguration();
     app.Use((context, next) =>
     {
         return next.Invoke();
     });
     app.UseStageMarker(PipelineStage.Authenticate);
     Swashbuckle.Bootstrapper.Init(config);
     WebApiConfig.Register(config);
     app.UseWebApi(config);
     app.UseStageMarker(PipelineStage.MapHandler);
 }
开发者ID:happyu0223,项目名称:CodeFirstIOCDemo,代码行数:17,代码来源:Bootstrap.cs

示例4: Configuration

        public void Configuration(IAppBuilder app)
        {
            ConfigureLogger();

            var builder = new ContainerBuilder();
            builder.RegisterLogger();
            builder.RegisterByAttributes(typeof (Startup).Assembly);
            builder.RegisterAssemblyModules(typeof (Startup).Assembly);
            builder.RegisterHubs(typeof (Startup).Assembly);
            var container = builder.Build();

            // config hubs
            var config = new HubConfiguration();
            config.Resolver = new AutofacDependencyResolver(container);

            app.UseJwtTokenAuthentication(container.Resolve<IssuerSetting>(),
                                          container.Resolve<AudienceSetting>(),
                                          container.Resolve<ClientSecretSetting>(),
                                          container.Resolve<ICurrentUserProvider>());

            app.MapSignalR(config);

            app.UseNancy(new NancyOptions
            {
                Bootstrapper = new NancyBootstrapper(container)
            });
            app.UseStageMarker(PipelineStage.MapHandler);
            app.UseCors(CorsOptions.AllowAll);

            JsonSettings.RetainCasing = false;

            SeedData(container);
        }
开发者ID:PatrickDinh,项目名称:Windtalker,代码行数:33,代码来源:Startup.cs

示例5: MiddlewaresAtDifferentStagesConfiguration

        public void MiddlewaresAtDifferentStagesConfiguration(IAppBuilder app)
        {
            app.Use((context, next) =>
            {
                //Create a custom object in the dictionary to push middlewareIds. 
                context.Set<Stack<int>>("stack", new Stack<int>());
                return next.Invoke();
            });

            var stageTuples = new Tuple<RequestNotification, PipelineStage>[]
                        {
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthenticateRequest, PipelineStage.Authenticate),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthenticateRequest, PipelineStage.PostAuthenticate),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthorizeRequest, PipelineStage.Authorize),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthorizeRequest, PipelineStage.PostAuthorize),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.ResolveRequestCache, PipelineStage.ResolveCache),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.ResolveRequestCache, PipelineStage.PostResolveCache),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.MapRequestHandler, PipelineStage.MapHandler),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.MapRequestHandler, PipelineStage.PostMapHandler),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AcquireRequestState, PipelineStage.AcquireState),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.AcquireRequestState, PipelineStage.PostAcquireState),
                            new Tuple<RequestNotification, PipelineStage>(RequestNotification.PreExecuteRequestHandler, PipelineStage.PreHandlerExecute),
                        };

            for (int middlewareId = 0; middlewareId < stageTuples.Length; middlewareId++)
            {
                var stage = stageTuples[middlewareId];
                app.Use<IntegratedPipelineMiddleware>(stage.Item1, middlewareId);
                app.UseStageMarker(stage.Item2);
            }
        }
开发者ID:Xamarui,项目名称:Katana,代码行数:31,代码来源:MiddlewaresAtDifferentStagesTest.cs

示例6: Configuration

        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
开发者ID:Paulie-Waulie,项目名称:TrainTrack,代码行数:26,代码来源:Startup.cs

示例7: Configuration

        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // set response formatters
            httpConfiguration.Formatters.Clear();
            SetWebApiResponseAsJson(httpConfiguration);

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}"
                );

            httpConfiguration.Routes.MapHttpRoute(
                name: "Default",
                routeTemplate: "r/{hashId}",
                defaults: new { controller = "RedirectUrl" }
                );

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./App/www"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
开发者ID:uthyat,项目名称:urlshortner,代码行数:35,代码来源:Startup.cs

示例8: DefaultStaticFiles

 public void DefaultStaticFiles(IAppBuilder app)
 {
     app.Use((context, next) => { context.Response.Headers["PassedThroughOWIN"] = "True"; return next(); });
     app.UseStaticFiles();
     app.Run(context => { context.Response.StatusCode = 402; return context.Response.WriteAsync("Fell Through"); });
     app.UseStageMarker(PipelineStage.MapHandler);
 }
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:7,代码来源:StaticFilesTests.cs

示例9: 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

示例10: Configuration

 public void Configuration(IAppBuilder app)
 {
     app.UseNancy();
     // todo: uncomment to invoke non-default Bootstrapper ctor
     //app.UseNancy(new NancyOptions() { Bootstrapper = new CustomBootstrapper(str: "hi") });
     app.UseStageMarker(PipelineStage.MapHandler);//required to display Nancy assets on IIS
 }
开发者ID:TheFastCat,项目名称:NancyBootstrapperLocatorIssue,代码行数:7,代码来源:Startup.cs

示例11: Configuration

        public void Configuration(IAppBuilder app)
        {
            JwtSecurityTokenHandler.InboundClaimTypeMap.Clear();

            app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority = "https://localhost:44333/core",
                RequiredScopes = new[] { "api" },
                NameClaimType = "name",
                RoleClaimType = "role",

                // client credentials for the introspection endpoint
                ClientId = "angularMaterial",
                ClientSecret = Guid.NewGuid().ToString()
            });

            var configuration = new HttpConfiguration();
            configuration.MapHttpAttributeRoutes();

            var jsonFormatter = configuration.Formatters.OfType<JsonMediaTypeFormatter>().FirstOrDefault();

            if (jsonFormatter != null)
            {
                jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            }

            app.UseResourceAuthorization(new AuthorizationManager());

            app.UseWebApi(configuration);

            app.UseNancy();
            app.UseStageMarker(PipelineStage.MapHandler);
        }
开发者ID:ianlovell,项目名称:openidconnect,代码行数:33,代码来源:Startup.cs

示例12: Configuration

 public void Configuration(IAppBuilder app)
 {
     Common.Setup.AutoMapper.Initialize();
     app.MapSignalR();
     app.UseNancy();
     app.UseStageMarker(PipelineStage.MapHandler);
 }    
开发者ID:rafazgz,项目名称:BB20151211-NancyFx,代码行数:7,代码来源:Startup.cs

示例13: 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

示例14: Configuration

        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            httpConfiguration.Formatters.Clear();
            httpConfiguration.Formatters.Add(new JsonMediaTypeFormatter());
            httpConfiguration.Formatters.JsonFormatter.SerializerSettings =
            new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./"),
                EnableDirectoryBrowsing = true,

            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
开发者ID:lanierhall-doubleline,项目名称:FullStack,代码行数:35,代码来源:Startup.cs

示例15: Configuration

        public void Configuration(IAppBuilder app)
        {
            var builder = new ContainerBuilder();
            builder.RegisterAssemblyModules(GetType().Assembly);
            var container = builder.Build();

            app.Use(typeof(StubJwtBearerAuthenticationMiddleware), app, new StubJwtBearerAuthenticationOptions("jwt"));
            app.UseStageMarker(PipelineStage.Authenticate);
            app.UseNancy(options =>
            {
                var bootstrapper = new FlogNancyBootstrapper()
                    .UseContainer(container);

                options.Bootstrapper = bootstrapper;
            });
            app.UseStageMarker(PipelineStage.MapHandler);
        }
开发者ID:niing,项目名称:Flog,代码行数:17,代码来源:Startup.cs


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