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


C# IAppBuilder.Map方法代码示例

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


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

示例1: ConfigureWebApi

        private void ConfigureWebApi(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{action}"
            );

            config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            app.Map("/api", api =>
            {
                var corsOptions = new CorsOptions()
                {
                    PolicyProvider = new CorsPolicyProvider
                    {
                        PolicyResolver = ctx =>
                        {
                            var policy = new CorsPolicy();
                            policy.Origins.Add("http://localhost:3054");
                            policy.AllowAnyHeader = true;
                            policy.Methods.Add("GET");
                            return Task.FromResult(policy);
                        }
                    }

                };
                api.UseCors(corsOptions);
                api.UseWebApi(config);
            });
        }
开发者ID:cecilphillipTK,项目名称:webapi2-security-samples,代码行数:34,代码来源:Startup.cs

示例2: Configuration

        public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            appBuilder.UseWebApi(config);

            var appFolder = Path.Combine(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName, "Webportal");

            appBuilder.UseFileServer(new Microsoft.Owin.StaticFiles.FileServerOptions
            {
                RequestPath = new PathString(WebPortalUrl),
                FileSystem = new PhysicalFileSystem(appFolder),
                EnableDirectoryBrowsing = true

            });

            appBuilder.Map(PathString.Empty, a => a.Use<PortalRedirectionMiddelware>(WebPortalUrl));
            appBuilder.Use<AdminMiddleware>();
        }
开发者ID:jormenjanssen,项目名称:Soundboard,代码行数:25,代码来源:PortalStartup.cs

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

示例4: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.Use<AddBreadCrumbMiddleware>("start-of-the-line");

            app.Map("/branch1", app1 =>
            {
                app1.Use<AddBreadCrumbMiddleware>("took-branch1");

                // Nesting paths, e.g. /branch1/branch2
                app1.Map("/branch2", app2 =>
                {
                    app2.Use<AddBreadCrumbMiddleware>("took-branch2");
                    app2.Use<DisplayBreadCrumbs>();
                });

                MapIfIE(app1);
                app1.Use<DisplayBreadCrumbs>();
            });

            // Only full segments are matched, so /branch1 does not match /branch100
            app.Map("/branch100", app1 =>
            {
                app1.Use<AddBreadCrumbMiddleware>("took-branch100");
                app1.Use<DisplayBreadCrumbs>();
            });

            MapIfIE(app);

            app.Use<AddBreadCrumbMiddleware>("no-branches-taken");
            app.Use<DisplayBreadCrumbs>();
        }
开发者ID:wk-j,项目名称:asp-samples,代码行数:31,代码来源:Startup.cs

示例5: Configuration

        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.Trace()
               .CreateLogger();

            app.UseAesDataProtectorProvider();
            app.Map("/admin", adminApp =>
                {
                    var factory = new IdentityManagerServiceFactory();
                   
                    factory.ConfigureSimpleIdentityManagerService("AspId");
                    //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK");

                    var adminOptions = new IdentityManagerOptions(){
                        Factory = factory
                    };
                    adminOptions.SecurityConfiguration.RequireSsl = false;
                    adminApp.UseIdentityManager(adminOptions);
                });

            var idSvrFactory = Factory.Configure();
            idSvrFactory.ConfigureUserService("AspId");

            var viewOptions = new ViewServiceOptions
            {
                TemplatePath = this.basePath.TrimEnd(new char[] { '/' })
            };
            idSvrFactory.ViewService = new IdentityServer3.Core.Configuration.Registration<IViewService>(new ViewService(viewOptions));

            var options = new IdentityServerOptions
            {
                SiteName = "IdentityServer3 - ViewSerive-AspNetIdentity",
                SigningCertificate = Certificate.Get(),
                Factory = idSvrFactory,
                RequireSsl = false,
                AuthenticationOptions = new AuthenticationOptions
                {
                    IdentityProviders = ConfigureAdditionalIdentityProviders,
                }
            };

            app.Map("/core", core =>
            {
                core.UseIdentityServer(options);
            });

            app.UseStaticFiles(new StaticFileOptions
            {
                RequestPath = new PathString("/Content"),
                FileSystem = new PhysicalFileSystem(Path.Combine(this.basePath, "Content")) 
            });

            var config = new HttpConfiguration();
          //  config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute("API", "api/{controller}/{action}", new { controller = "Home", action = "Get" });
            app.UseWebApi(config);
        }
开发者ID:mequanta,项目名称:Janitor-old,代码行数:60,代码来源:Startup.cs

示例6: Configuration

        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {

                        // Configure Web API for self-host. 
            HttpConfiguration config = ConfigurationBuilder.HttpConfiguration;
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute("MyROute", "jobs/{name}/trigger", new {controller = "Jobs", action = "PostTriggerJob"});


            appBuilder.UseFileServer(new FileServerOptions()
            {
                FileSystem = new PhysicalFileSystem("./Assets/assets"),
                RequestPath = new PathString("/assets")
            });

            
            appBuilder.Map("/quartzadmin", builder => builder.UseNancy());

            appBuilder.Map("/api", builder => builder.UseWebApi(config));

            


            //appBuilder.UseWebApi(config);
        }
开发者ID:kaleyroy,项目名称:QuartzNetAPI,代码行数:34,代码来源:Startup.cs

示例7: Configuration

		public void Configuration(IAppBuilder app)
		{
			//app.Run(async context => await context.Response.WriteAsync("Hello!"));

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

			app.Map("/class", classApp => classApp.UseHelloWorld(
				new HelloWorldOptions() { Greeting = "Hello from Middleware Class" }));

			app.Map("/owin", owinApp =>
			{
				var middleware = new Func<AppFunc, AppFunc>(next =>
					async env =>
					{
						var bytes = Encoding.UTF8.GetBytes("Hello OWIN!");
						var headers = (IDictionary<string, string[]>)env["owin.ResponseHeaders"];
						headers["Content-Type"] = new[] { "text/html" };
						var response = (Stream)env["owin.ResponseBody"];
						await response.WriteAsync(bytes, 0, bytes.Length);

						await next(env);
					});
				owinApp.Use(middleware);
			});
		}
开发者ID:mkandroid15,项目名称:Samples,代码行数:30,代码来源:Program.cs

示例8: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.Map("/idmgr", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("DefaultConnection");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            app.Map("/idsvr", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("DefaultConnection");

                var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3 - UserService-AspNetIdentity",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    }
                };

                core.UseIdentityServer(options);
            });
        }
开发者ID:dtuit,项目名称:IdentityServer_BasicSetup,代码行数:32,代码来源:Startup.cs

示例9: Configuration

        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            Log.Logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.Trace()
               .CreateLogger();

            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });

            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");

                var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3 - AspNetIdentity 2FA",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                };

                core.UseIdentityServer(options);
            });
        }
开发者ID:RobGibbens,项目名称:IdentityServer3.Samples,代码行数:34,代码来源:Startup.cs

示例10: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.Map("/admin", adminApp =>
            {
                var factory = new IdentityManagerServiceFactory();
                factory.ConfigureSimpleIdentityManagerService("AspId");

                adminApp.UseIdentityManager(new IdentityManagerOptions()
                {
                    Factory = factory
                });
            });
            app.Map("/core", core =>
            {
                var idSvrFactory = Factory.Configure();
                idSvrFactory.ConfigureUserService("AspId");

                var options = new IdentityServerOptions
                {
                    SiteName = "Thinktecture IdentityServer3 - AspNetIdentity 2FA",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                };

                core.UseIdentityServer(options);
            });
        }
开发者ID:MauricioArroyo,项目名称:IdentityServer3.Samples,代码行数:27,代码来源:Startup.cs

示例11: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR<SendingConnection>("/sending-connection");
            app.MapSignalR<TestConnection>("/test-connection");
            app.MapSignalR<RawConnection>("/raw-connection");
            app.MapSignalR<StreamingConnection>("/streaming-connection");

            app.Use(typeof(ClaimsMiddleware));

            ConfigureSignalR(GlobalHost.DependencyResolver, GlobalHost.HubPipeline);

            var config = new HubConfiguration()
            {
                EnableDetailedErrors = true
            };

            app.MapSignalR(config);

            app.Map("/cors", map =>
            {
                map.UseCors(CorsOptions.AllowAll);
                map.MapSignalR<RawConnection>("/raw-connection");
                map.MapSignalR();
            });

            app.Map("/basicauth", map =>
            {
                map.UseBasicAuthentication(new BasicAuthenticationProvider());
                map.MapSignalR<AuthenticatedEchoConnection>("/echo");
                map.MapSignalR();
            });

            BackgroundThread.Start();
        }
开发者ID:nirmana,项目名称:SignalR,代码行数:34,代码来源:Startup.cs

示例12: Configuration

        public void Configuration(IAppBuilder app)
        {
            // this configures IdentityManager
            // we're using a Map just to test hosting not at the root
            app.Map("/idm", idm =>
            {
                LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());

                var factory = new IdentityManagerServiceFactory();

                var rand = new System.Random();
                var users = Users.Get(rand.Next(5000, 20000));
                var roles = Roles.Get(rand.Next(15));

                factory.Register(new Registration<ICollection<InMemoryUser>>(users));
                factory.Register(new Registration<ICollection<InMemoryRole>>(roles));
                factory.IdentityManagerService = new Registration<IIdentityManagerService, InMemoryIdentityManagerService>();

                idm.UseIdentityManager(new IdentityManagerOptions
                {
                    Factory = factory,
                    SecurityMode = SecurityMode.LocalMachine,
                    OAuth2Configuration = new OAuth2Configuration
                    {
                        AuthorizationUrl = "http://localhost:17457/ids/connect/authorize",
                        Issuer = "https://idsrv3.com",
                        Audience = "https://idsrv3.com/resources",
                        ClientId = "idmgr",
                        SigningCert = Cert.Load(),
                        Scope = "idmgr",
                        ClaimsTransformation = user =>
                        {
                            if (user.IsInRole("Foo"))
                            {
                                ((ClaimsIdentity)user.Identity).AddClaim(new Claim("role", "IdentityManagerAdministrator"));
                            }
                            
                            return user;
                        },
                        //PersistToken = true,
                        //AutomaticallyRenewToken = true
                    }
                });
            });

            // this configures an embedded IdentityServer to act as an external authentication provider
            // when using IdentityManager in Token security mode. normally you'd configure this elsewhere.
            app.Map("/ids", ids =>
            {
                IdSvrConfig.Configure(ids);
            });

            // used to redirect to the main admin page visiting the root of the host
            app.Run(ctx =>
            {
                ctx.Response.Redirect("/idm/");
                return System.Threading.Tasks.Task.FromResult(0);
            });
        }
开发者ID:krunalm,项目名称:Thinktecture.IdentityManager,代码行数:59,代码来源:Startup.cs

示例13: Configuration

        public void Configuration(IAppBuilder app)
        {
            // When we call the base address + /stringPage
            app.Map("/stringPage", UseTheStringResponder);

            // When we call the base address + /htmlPage
            app.Map("/htmlPage", UseTheHtmlResponder);
        }
开发者ID:johndarv,项目名称:CSharpExamples,代码行数:8,代码来源:Startup.cs

示例14: CombinedConfig

 static void CombinedConfig(IAppBuilder builder)
 {
     builder.Map("/eventsource", EventSourceSample.BuildSample);
     builder.Map("/routeheader", RouteHeaderSample.BuildSample);
     builder.Map("/routequery", RouteQuerySample.BuildSample);
     builder.Map("/routeparams", RouteParamsSample.BuildSample);
     builder.Map("/branchsample", RouteBranchSample.BuildSample);
 }
开发者ID:Xamarui,项目名称:OwinUtils,代码行数:8,代码来源:Program.cs

示例15: Configuration

        public void Configuration(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .WriteTo.Trace()
                .CreateLogger();

            //LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());

            var builder = new ContainerBuilder();

            Modules.Register(builder);

            var container = builder.Build();

            using (var scope = container.BeginLifetimeScope())
            {
                app.Map("/core", coreApp =>
                {
                    scope.Resolve<IdentityServerBootstrapper>().Run(coreApp);
                });

                app.Map("/admin", adminApp =>
                {
                    scope.Resolve<IdentityAdminBootstrapper>().Run(adminApp);
                });

                app.Map("/manage", manageApp =>
                {
                    scope.Resolve<IdentityManagerBootstrapper>().Run(manageApp);
                });
                //app.Map("/memory", memoryApp =>
                //{
               // using IdentityManager;
               // using IdentityManager.Configuration;
               // using System.Collections.Generic;

                //    var factory = new IdentityManagerServiceFactory
                //    {

                //    };

                //    var rand = new System.Random();
                //    var users = new List<InMemoryUser>();
                //    var roles = new List<InMemoryRole>();

                //    factory.Register(new Registration<ICollection<InMemoryUser>>(users));
                //    factory.Register(new Registration<ICollection<InMemoryRole>>(roles));
                //    factory.IdentityManagerService = new Registration<IIdentityManagerService, InMemoryIdentityManagerService>();

                //    memoryApp.UseIdentityManager(new IdentityManagerOptions
                //    {
                //        Factory = factory,
                //    });
                //});
            }
        }
开发者ID:ianlovell,项目名称:openidconnect,代码行数:58,代码来源:Startup.cs


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