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


C# IApplicationBuilder.Map方法代码示例

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


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

示例1: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseWebSockets();
            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.Map("/Preview/Socket", PreviewSocketHandler.Map);
            app.Map("/Index/Socket", DashboardSocketHandler.Map);
            app.Map("/SACNTransmitters/Socket", SACNTransmitterLive.Map);
            app.Map("/OSCListeners/Socket", OSCListenerLive.Map);
            app.Map("/RawDMX/Socket", RawDMXSocketHandler.Map);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:iKadmium,项目名称:kadmium-osc-dmx-dotnet,代码行数:32,代码来源:Startup.cs

示例2: Configure

        public void Configure(IApplicationBuilder app)
        {
            var settings = app.ApplicationServices.GetService<IOptions<AppSettings>>();

            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());

            app.Map("/core", core =>
            {
                var factory = InMemoryFactory.Create(
                                        users: Users.Get(),
                                        clients: Clients.Get(),
                                        scopes: Scopes.Get());

                var cors = new DefaultCorsPolicyService
                {
                    AllowAll = true
                };
                factory.CorsPolicyService = new Registration<ICorsPolicyService>(cors);

                var idsrvOptions = new IdentityServerOptions
                {
                    LoggingOptions = new LoggingOptions
                    {
                        IncludeSensitiveDataInLogs = true,
                        //WebApiDiagnosticsIsVerbose = true,
                        //EnableWebApiDiagnostics = true
                    },
                    IssuerUri = settings.Options.IssuerUrl,
                    SiteName = settings.Options.SiteTitle,
                    Factory = factory,
                    SigningCertificate = Certificate.Get(),
                    RequireSsl = false,
                    AuthenticationOptions = new AuthenticationOptions
                    {

                    }
                };

                core.UseIdentityServer(idsrvOptions);
            });

            app.Map("/api", api =>
            {
                api.UseOAuthBearerAuthentication(options => {
                    options.Authority = settings.Options.AuthorizationUrl;
                    options.MetadataAddress = settings.Options.AuthorizationUrl + "/.well-known/openid-configuration";
                    options.TokenValidationParameters.ValidAudience = settings.Options.BaseUrl + "/resources";
                });

                // for web api
                api.UseMvc();
            });
        }
开发者ID:marcelo-mason,项目名称:Angular-WebAPI-Boilerplate,代码行数:53,代码来源:IdentityServerMiddleware.cs

示例3: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.Map("/echo", config => config.Run(async context =>
            {
                var path = context.Request.Path.ToString();
                await context.Response.WriteAsync(path);
            }));

            app.Map("/upper", config => config.Run(async context =>
            {
                var path = context.Request.Path.ToString().ToUpper();
                await context.Response.WriteAsync(path);
            }));
        }
开发者ID:joekrie,项目名称:aspnet5-primer,代码行数:14,代码来源:Startup.cs

示例4: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            //
            // Scenarios:
            // 1. Multiple services.
            // 2. Various versions or kinds of clients side by side.
            //

            //
            // SMS
            //
            app.Map("/sms",
                subApp =>
                {
                    subApp.RunGateway(new GatewayOptions() { ServiceDescription = new SmsServiceDescription() });
                }
            );

            //
            // Counter
            //
            app.Map("/counter",
                subApp =>
                {
                    subApp.RunGateway(new GatewayOptions() { ServiceDescription = new CounterServiceDescription() });
                }
            );

            app.Map("/Hosting/CounterService",
                subApp =>
                {
                    subApp.RunGateway(new GatewayOptions() { ServiceDescription = new CounterServiceDescription() });
                }
            );

            app.MapWhen(
                context =>
                {
                    StringValues serviceNames;

                    return context.Request.Headers.TryGetValue("SF-ServiceName", out serviceNames) &&
                           serviceNames.Count == 1 &&
                           serviceNames[0] == "fabric:/Hosting/CounterService";
                },
                subApp =>
                {
                    subApp.RunGateway(new GatewayOptions() { ServiceDescription = new CounterServiceDescription() });
                }
            );
        }
开发者ID:IllyriadGames,项目名称:Hosting,代码行数:51,代码来源:Startup.cs

示例5: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            // Configuration
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            builder.AddEnvironmentVariables();
            builder.Build();

            // Logging
            loggerFactory.AddDebug(minLevel: LogLevel.Verbose);
            
            // Using different environments
            if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { }

            // Middlewares
            app.UseDeveloperExceptionPage();
            app.UseRuntimeInfoPage(); // default path is /runtimeinfo            
            app.UseDefaultFiles();
            app.UseStaticFiles();

            // Web sockets
            app.Map("/Managed", (appBuilder) => WebSocketsHelper.Configure(appBuilder, loggerFactory));

            // IIS
            app.UseIISPlatformHandler();
        }
开发者ID:streamcode9,项目名称:chat,代码行数:29,代码来源:Startup.cs

示例6: Configure

		public void Configure(IApplicationBuilder app)
		{
			app.UseMvc();

			app.Map("/site", siteApp =>
			{
				siteApp.UseFileServer(new FileServerOptions
				{
					FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")),
					EnableDirectoryBrowsing = true
				});
			});

			app.Use(async (context, next) =>
			{
				await context.Response.WriteAsync("=== BEFORE ===");
				await next();
				await context.Response.WriteAsync("=== AFTER ===");
			});

			app.Run(async (context) =>
			{
				Console.WriteLine($"Got request for {context.Request.Path}");

				await context.Response.WriteAsync(
					[email protected]"<!DOCTYPE 'html'><html><body><h1>Hello from {
						context.Request.Path }!</h1></body></html>");
			});
		}
开发者ID:mkandroid15,项目名称:Samples,代码行数:29,代码来源:Startup.cs

示例7: Configure

        public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
        {
            var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";

            app.Map("/core", core =>
            {
                var factory = InMemoryFactory.Create(

                                clients: Clients.Get(),
                                scopes: Scopes.Get());

                var userService = new UserService();
                factory.UserService = new Registration<IUserService>(resolver => userService);
                // factory.ViewService = new Registration<IViewService>(typeof(CustomViewService));

                var idsrvOptions = new IdentityServerOptions
                {
                    IssuerUri = "",
                    Factory = factory,
                    RequireSsl = false,
                    LoggingOptions =
                    // SigningCertificate = new X509Certificate2(certFile, "idsrv3test")
                };

                core.UseIdentityServer(idsrvOptions);
            });
开发者ID:reddychaitanya,项目名称:Identity,代码行数:26,代码来源:Startup.cs

示例8: Configure

        public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
        {
            app.UseIISPlatformHandler();
            app.UseDeveloperExceptionPage();

            var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";

            app.Map("/identity", idsrvApp =>
            {
                idsrvApp.UseIdentityServer(new IdentityServerOptions
                {
                    SiteName = "Embedded IdentityServer",
                    SigningCertificate = new X509Certificate2(certFile, "idsrv3test"),

                    Factory = new IdentityServerServiceFactory()
                                .UseInMemoryUsers(Users.Get())
                                .UseInMemoryClients(Clients.Get())
                                .UseInMemoryScopes(Scopes.Get()),

                    AuthenticationOptions = new IdentityServer3.Core.Configuration.AuthenticationOptions
                    {
                        EnableLocalLogin = false,
                        IdentityProviders = ConfigureIdentityProviders,
                        SignInMessageThreshold = 5
                    }
                });
            });

            app.UseCors("mypolicy");
            app.UseMvc();
        }
开发者ID:Stavrakakis,项目名称:Pickle,代码行数:31,代码来源:Startup.cs

示例9: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(LogLevel.Debug);
			
            app.Map(
                new PathString("/onboarding"),
                branch => branch.Run(async ctx =>
                {
                    await ctx.Response.WriteAsync("Onboarding");
                })
            );

            app.UseMultitenancy<AppTenant>();

            app.Use(async (ctx, next) =>
            {
                if (ctx.GetTenant<AppTenant>().Name == "Default")
                {
                    ctx.Response.Redirect("/onboarding");
                } else
                {
                    await next();
                }
            });

            app.UseMiddleware<LogTenantMiddleware>();
        }
开发者ID:rdefreitas,项目名称:saaskit,代码行数:28,代码来源:Startup.cs

示例10: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseMiddleware<RequestDurationMiddleware>();

            app.Use(async (context, next) =>
            {
                await context.Response.WriteAsync("Hi Cancel!<br/>");
                await next.Invoke();
                await context.Response.WriteAsync("<br/>I'm done.");
            });

            app.Map("/diagnostics", c =>
            {
                c.Run(async ctx =>
               {
                   var feature = ctx.GetFeature<IHttpConnectionFeature>();
                   await ctx.Response.WriteAsync("Hello Diagnostics test from " +  feature.RemoteIpAddress);
               });
            });

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
开发者ID:rafsan,项目名称:Cancel,代码行数:25,代码来源:Startup.cs

示例11: Configure

        public void Configure(IApplicationBuilder app)
        {

            //app.Map("", (a) =>
            //{
            //    a.UseWebSockets(new WebSocketOptions() { ReplaceFeature = true });
            //    a.Use<IWebSocketHandler>(async (context, next, handler) =>
            //    {
            //        if (!context.IsWebSocketRequest)
            //        {
            //            await next();
            //            return;
            //        }

            //        await handler.MessageLoopAsync();
            //    });
            //});

            app.Map("", (a) =>
            {
                a.UseWebSockets(new WebSocketOptions() { ReplaceFeature = true });
                a.Use(async (context, next) =>
                {
                    if (!context.IsWebSocketRequest)
                    {
                        await next();
                        return;
                    }

                    var factory = a.ApplicationServices.GetService<SessionFactory>();
                    var handler = new SessionHandler(context, factory);
                    await handler.MessageLoopAsync();
                });
            });
        }
开发者ID:hpatel98,项目名称:SCAMP,代码行数:35,代码来源:Startup.cs

示例12: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            if(env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            
            loggerFactory
                .AddConsole(Configuration.GetSection("Logging"))
                .AddDebug();
            
            // Use the Default files ['index.html', 'index.htm', 'default.html', 'default.htm']
            app.UseDefaultFiles()
                .UseStaticFiles()
                .UseIISPlatformHandler()
                .UseMvc();

            // Setup a generic Quotes API EndPoint
            app.Map("/api/quotes", (config) =>
            {
                app.Run(async context =>
                {
                    var quotes = "{ \"quotes\":" +
                                 " [ { \"quote\": \"Duct tape is like the force. It has a light side, a dark side, and it holds the universe together.\", \"author\":\"Oprah Winfrey\"} ]" +
                                 "}";
                    context.Response.ContentLength = quotes.Length;
                    context.Response.ContentType = "application/json";                    
                    await context.Response.WriteAsync(quotes);
                });
            });
        }
开发者ID:jtucker,项目名称:aspnet5-angular2-starter,代码行数:32,代码来源:Startup.cs

示例13: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseSession();

            app.Map("/session", subApp =>
            {
                subApp.Run(async context =>
                {
                    int visits = 0;
                    visits = context.Session.GetInt32("visits") ?? 0;
                    context.Session.SetInt32("visits", ++visits);
                    await context.Response.WriteAsync("Counting: You have visited our page this many times: " + visits);
                });
            });

            app.Run(async context =>
            {
                int visits = 0;
                visits = context.Session.GetInt32("visits") ?? 0;
                await context.Response.WriteAsync("<html><body>");
                if (visits == 0)
                {
                    await context.Response.WriteAsync("Your session has not been established.<br>");
                    await context.Response.WriteAsync(DateTime.Now + "<br>");
                    await context.Response.WriteAsync("<a href=\"/session\">Establish session</a>.<br>");
                }
                else
                {
                    context.Session.SetInt32("visits", ++visits);
                    await context.Response.WriteAsync("Your session was located, you've visited the site this many times: " + visits);
                }
                await context.Response.WriteAsync("</body></html>");
            });
        }
开发者ID:yaobos,项目名称:Session,代码行数:34,代码来源:Startup.cs

示例14: Configure

        public void Configure(IApplicationBuilder app, IApplicationLifetime lifetime, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            app.Map("/simplewebapi", (app1) => this.ConfigureIIS(app1, lifetime, env, loggerFactory));

            app.UseMvc();

            app.UseWelcomePage();
        }
开发者ID:jsacapdev,项目名称:simplewebapi,代码行数:8,代码来源:Startup.cs

示例15: MockAuthorizationPipeline_OnPostConfigure

        private void MockAuthorizationPipeline_OnPostConfigure(IApplicationBuilder app)
        {
            app.Map(Constants.RoutePaths.Login.EnsureLeadingSlash(), path =>
            {
                path.Run(ctx => Login(ctx));
            });

            app.Map(Constants.RoutePaths.Consent.EnsureLeadingSlash(), path =>
            {
                path.Run(ctx => Consent(ctx));
            });

            app.Map(Constants.RoutePaths.Error.EnsureLeadingSlash(), path =>
            {
                path.Run(ctx => Error(ctx));
            });
        }
开发者ID:RajMondaz,项目名称:IdentityServer4,代码行数:17,代码来源:MockAuthorizationPipeline.cs


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