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


C# IAppBuilder.UseNancy方法代码示例

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


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

示例1: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.Use((ctx, next) =>
            {
                var output = ctx.Get<TextWriter>("host.TraceOutput");
                output.WriteLine("{0} {1}: {2}", ctx.Request.Scheme, ctx.Request.Method, ctx.Request.Path);
                return next();
            });
            GlobalHost.DependencyResolver.Register(typeof(VoteHub),
                () => new VoteHub(new QuestionRepository()));

            app.UseStaticFiles();
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            //app.MapSignalR();
            app.Map("/signalr", map => map.UseCors(CorsOptions.Value)
                 .RunSignalR(new HubConfiguration
                 {
                     EnableJSONP = true
                 }));

            app.UseNancy(options =>
                    options.PerformPassThrough = context =>
                        context.Response.StatusCode == HttpStatusCode.NotFound);
            
            app.Run(context =>
            {
                context.Response.ContentType = "text/plain";
                return context.Response.WriteAsync("Hello World!");
            });
        }
开发者ID:rhwy,项目名称:Demos-Angular-SignalR,代码行数:30,代码来源:Startup.cs

示例2: Configuration

 public void Configuration(IAppBuilder app)
 {
     if (SetNancyFlag(app))
     {
         app.UseNancy();
     }
 }
开发者ID:loudej,项目名称:NancySignalR,代码行数:7,代码来源:NancyAutoStartup.cs

示例3: Configuration

        public void Configuration(IAppBuilder app)
        {
            var option = new NancyOptions
            {
                Bootstrapper = new Bootstrapper(),
                PerformPassThrough = context =>
                  context.Response.StatusCode == HttpStatusCode.NotFound
            };

            //option.PassThroughWhenStatusCodesAre(HttpStatusCode.ServiceUnavailable);
            app.UseNancy(option);
            //app.UseNancy();

            app.Map("/core",
            coreApp =>
            {
                coreApp.UseIdentityServer(new IdentityServerOptions
                {
                    SiteName = "Standalone Identity Server",
                    SigningCertificate = Certificate.Get(),
                    Factory = new IdentityServerServiceFactory()
                            .UseInMemoryClients(Clients.Get())
                            .UseInMemoryScopes(Scopes.Get())
                            .UseInMemoryUsers(Users.Get())
                });
            });
        }
开发者ID:tuvoksg1,项目名称:ProvingGround,代码行数:27,代码来源:Startup.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: 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

示例6: Configuration

		public void Configuration(IAppBuilder app)
		{
			app.UseNancy(x =>
			{
				x.Bootstrapper = new CustomConventionsNancy();
			});
		}
开发者ID:yangecnu,项目名称:elasticsearch-net-example,代码行数:7,代码来源:Bootstrap.cs

示例7: Configuration

        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888

            // Static file support.
            var baseDir = AppDomain.CurrentDomain.BaseDirectory;
            app.UseStaticFiles(new StaticFileOptions
            {
                FileSystem = new PhysicalFileSystem(root: baseDir),
                ServeUnknownFileTypes = false
            });

            // ASP.NET Web API support.
            var config = new HttpConfiguration();
            
            // Fix: CORS support of WebAPI doesn't work on mono. http://stackoverflow.com/questions/31590869/web-api-2-post-request-not-working-on-mono
            if (Type.GetType("Mono.Runtime") != null) config.MessageHandlers.Add(new MonoPatchingDelegatingHandler());

            config.EnableCors();
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            app.UseWebApi(config);

            // NancyFx support.
            app.UseNancy();
        }
开发者ID:jsakamoto,项目名称:chomado-problem-server,代码行数:30,代码来源:Startup.cs

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

示例9: Configuration

        public void Configuration(IAppBuilder appBuilder)
        {
            // Host all the WebAPI components underneath a path so we can
            //  easily deploy a traditional site at the root of the web
            //  application
            //
            appBuilder.Map("/api", api =>
            {
                // This object is what we use to configure the behavior
                //  of WebAPI in our application
                //
                var httpConfiguration = new HttpConfiguration();

                // We'll use attribute based routing instead of the
                //  convention-based approach
                //
                httpConfiguration.MapHttpAttributeRoutes();

                // Change the serialization so it does camelCase
                //
                var jsonFormatter = httpConfiguration.Formatters.JsonFormatter;
                var settings = jsonFormatter.SerializerSettings;
                settings.ContractResolver = new CamelCasePropertyNamesContractResolver();

                // Now add in web api to the OWIN pipeline
                //
                api.UseWebApi(httpConfiguration);
            });

            // Add nancy to the pipeline after WebAPI so the API can
            //  handle any requests it is configured for first
            //
            appBuilder.UseNancy();
        }
开发者ID:kfukue,项目名称:experiments,代码行数:34,代码来源:Startup.cs

示例10: Configuration

 public void Configuration(IAppBuilder app)
 {
     app.UseNancy(options =>
     {
         options.Bootstrapper = new Bootstrapper();
     });
 }
开发者ID:dcomartin,项目名称:Nancy.MediatR,代码行数:7,代码来源:Program.cs

示例11: Configuration

 public void Configuration(IAppBuilder app)
 {
     app.UseNancy(new Nancy.Owin.NancyOptions
     {
         Bootstrapper = new DefaultNancyBootstrapper()
     });
 }
开发者ID:KatsuYuzu,项目名称:LightNode,代码行数:7,代码来源:Startup.cs

示例12: 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)
        {
            // We're going to hang the web API off off the /api "sub"-url so that we
            //  leave the root url open for the Angular 2 website.
            //
            appBuilder.Map("/api", api =>
            {
                // Create our config object we'll use to configure the API
                //
                var config = new HttpConfiguration();

                // Use attribute routing
                //
                config.MapHttpAttributeRoutes();

                // Now add in the WebAPI middleware
                //
                api.UseWebApi(config);
            });

            // Add Nancy to the OWIN pipeline.
            //  Note, because this is registered last we don't need to worry
            //  about falling-through to any other middleware. Any requests to
            //  /api/... will be handled by WebAPI first, and anything else
            //  will fall through to Nancy
            //
            appBuilder.UseNancy();
        }
开发者ID:kfukue,项目名称:experiments,代码行数:31,代码来源:Startup.cs

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

示例14: Configure

        public static void Configure(IAppBuilder app, IContainer container)
        {
            var webConfiguration = new WebConfiguration();

            string absolutePath = null;
            if (webConfiguration.NancyViewPath != null)
            {
                var isPathRooted = Path.IsPathRooted(webConfiguration.NancyViewPath);
                if (isPathRooted)
                {
                    absolutePath = webConfiguration.NancyViewPath;
                }
                else
                {
                    var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
                    absolutePath = Path.Combine(baseDirectory, webConfiguration.NancyViewPath);
                    absolutePath = Path.GetFullPath(absolutePath);
                }
            }

            AutofacNancyBootstrapper.RootPath = absolutePath;
            AutofacNancyBootstrapper.Container = container;

            app.UseNancy(new NancyOptions
            {
                PerformPassThrough = context => context.Response.StatusCode == HttpStatusCode.NotFound
            });
        }
开发者ID:StanleyGoldman,项目名称:NycDataVizualizations,代码行数:28,代码来源:NancyConfig.cs

示例15: Configuration

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

            app.ConfigureMembershipReboot();
            app.UseNancy();
        }
开发者ID:neogodless,项目名称:BrockAllen.MembershipReboot,代码行数:7,代码来源:Startup.cs


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