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


C# IAppBuilder.UseNinjectMiddleware方法代码示例

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


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

示例1: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            DataProtectionProvider = app.GetDataProtectionProvider();
            // Configure the db context and user manager to use a single instance per request
            //app.CreatePerOwinContext(ApplicationDbContext.Create);
            app.CreatePerOwinContext(CreateKernel);
            app.UseNinjectMiddleware(CreateKernel);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                AccessTokenFormat = new HunterJwtFormat("http://localhost:53147/"),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            //app.UseOAuthBearerTokens(OAuthOptions);
            app.UseOAuthAuthorizationServer(OAuthOptions);
            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseLinkedInAuthentication(
            //    "<YOUR API KEY>",
            //    "<YOUR SECRET KEY>"
            //    );
        }
开发者ID:Budzyn,项目名称:hunter,代码行数:36,代码来源:Startup.Auth.cs

示例2: Configuration

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

            var webApiConfiguration = new HttpConfiguration();
            //use camelcase
            var formatters = webApiConfiguration.Formatters;
            var jsonFormatter = formatters.JsonFormatter;
            var settings = jsonFormatter.SerializerSettings;
            settings.Formatting = Formatting.Indented;
            settings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            //enable cors for pretty much everything
            var cors = new EnableCorsAttribute("*", "*", "*");
            webApiConfiguration.EnableCors(cors);

            webApiConfiguration.MapHttpAttributeRoutes();

            webApiConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional, controller = "values" });

            app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(webApiConfiguration);
        }
开发者ID:ARozar,项目名称:LearningTypeScript,代码行数:25,代码来源:Startup.cs

示例3: Configuration

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

            app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(GlobalConfiguration.Configuration);

        }
开发者ID:jesusico83,项目名称:Telerik,代码行数:7,代码来源:Startup.cs

示例4: Configuration

        public void Configuration(IAppBuilder app)
        {
            var config = CreateHttpConfiguration();

            app.UseNinjectMiddleware(Ninject.CreateKernel);
            app.UseNinjectWebApi(config);
        }
开发者ID:alexvance89,项目名称:tinder-api,代码行数:7,代码来源:Startup.cs

示例5: UseWebApi

            private static void UseWebApi(IAppBuilder application, IKernel kernel)
            {
                var config = new HttpConfiguration();
                config.MapHttpAttributeRoutes();
                var cors = new EnableCorsAttribute("*", "*", "*");

                //GlobalConfiguration.Configure(configuration =>
                //{
                //    configuration.SuppressDefaultHostAuthentication();
                //    configuration.MapHttpAttributeRoutes();
                //    configuration.EnableCors(cors);
                //    configuration.Filters.Add(new HostAuthenticationAttribute(OAuthDefaults.AuthenticationType));
                //    var jsonformatter = configuration.Formatters.JsonFormatter;
                //    jsonformatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                //    configuration.AddJsonpFormatter();
                //    application.UseNinjectMiddleware(() => kernel);
                //    application.UseNinjectWebApi(configuration);
                //    application.UseWebApi(configuration);
                //});
                config.SuppressDefaultHostAuthentication();
                ConfigureOAuth(application);
                config.EnableCors(cors);
                config.Filters.Add(new HostAuthenticationAttribute(OAuthDefaults.AuthenticationType));
                var jsonformatter = config.Formatters.JsonFormatter;
                jsonformatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                config.AddJsonpFormatter();

                application.UseNinjectMiddleware(() => kernel);
                application.UseNinjectWebApi(config);
                application.UseWebApi(config);

                application.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            }
开发者ID:buenokinder,项目名称:blacksails-middleware,代码行数:33,代码来源:StartupConfig.cs

示例6: Configuration

        public void Configuration(IAppBuilder app)
        {
            var policy = new CorsPolicy
            {
                AllowAnyHeader = true,
                AllowAnyMethod = true,
                SupportsCredentials = true
            };

            policy.ExposedHeaders.Add("Authorization");

            app.UseCors(new CorsOptions
            {
                PolicyProvider = new CorsPolicyProvider
                {
                    PolicyResolver = context => Task.FromResult(policy)
                }
            });

            var config = new HttpConfiguration();

            WebApiConfig.Register(config);

            app.UseNinjectMiddleware(CreateKernel);
            app.UseNinjectWebApi(config);

        }
开发者ID:IbrahimAmin,项目名称:MR-Reporting-System,代码行数:27,代码来源:Startup.cs

示例7: Configuration

        public void Configuration(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);

            ConfigureAuth(app);
            app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(GlobalConfiguration.Configuration);
        }
开发者ID:GeorgiNik,项目名称:TelerikAcademy,代码行数:7,代码来源:Startup.cs

示例8: Configuration

        public void Configuration(IAppBuilder app)
        {
            var webApiConfiguration = new HttpConfiguration();
            webApiConfiguration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            webApiConfiguration.MapHttpAttributeRoutes();

            app
                .UseNinjectMiddleware(CreateKernel)
                .UseNinjectWebApi(webApiConfiguration)
                .UseFileServer(new FileServerOptions
                {
                    EnableDefaultFiles = false,
                    EnableDirectoryBrowsing = false,
                    StaticFileOptions =
                    {
                        RequestPath = new PathString("/css"),
                        FileSystem = new PhysicalFileSystem(BaseDirectory + "\\content"),
                        ContentTypeProvider = new FileExtensionContentTypeProvider(
                            new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
                            {
                                {".css", "text/css"}
                            })
                    }
                })
                .UseFileServer(new FileServerOptions
                {
                    EnableDefaultFiles = false,
                    EnableDirectoryBrowsing = false,
                    StaticFileOptions =
                    {
                        RequestPath = new PathString("/js"),
                        FileSystem = new PhysicalFileSystem(BaseDirectory + "\\scripts"),
                        ContentTypeProvider = new FileExtensionContentTypeProvider(
                            new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
                            {
                                {".js", "application/javascript"}
                            })
                    }
                })
                .UseFileServer(new FileServerOptions
                {
                    EnableDefaultFiles = true,
                    DefaultFilesOptions =
                    {
                        DefaultFileNames = { "index.html" }
                    },
                    EnableDirectoryBrowsing = false,
                    StaticFileOptions =
                    {
                        RequestPath = new PathString(""),
                        FileSystem = new PhysicalFileSystem(BaseDirectory + "\\static"),
                        ContentTypeProvider = new FileExtensionContentTypeProvider(
                            new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
                            {
                                {".html", "text/html"}
                            })
                    }
                });
        }
开发者ID:pmccloghrylaing,项目名称:numeric-sequencer,代码行数:59,代码来源:Startup.cs

示例9: Configuration

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

            WebApiConfig.Register(config);
            app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(config);
        }
开发者ID:Malkiat-Singh,项目名称:webApiAngular,代码行数:8,代码来源:Startup.cs

示例10: Configuration

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

            WebApiConfig.Register(config);

            app.UseNinjectMiddleware(() => kernel.Value).UseNinjectWebApi(config);
        }
开发者ID:paulsonnentag,项目名称:schaudepot,代码行数:8,代码来源:Startup.cs

示例11: Configuration

        /// <summary>
        /// Configures the OWIN runtime
        /// </summary>
        /// <param name="app">The application builder</param>
        public void Configuration(IAppBuilder app)
        {
            app.UseOAuthAuthorizationServer(BlobstoreConfiguration.CreateAuthorizationOptions());
            app.UseOAuthBearerAuthentication(BlobstoreConfiguration.CreateAuthenticationOptions());
            app.UseNinjectMiddleware(BlobstoreConfiguration.CreateKernel);

            app.UseNinjectWebApi(BlobstoreConfiguration.CreateHttpConfiguration(AddElmahHandleErrorApiAttribute));
        }
开发者ID:froko,项目名称:bbv.Blobstore,代码行数:12,代码来源:Startup.cs

示例12: Configuration

 public void Configuration(IAppBuilder appBuilder)
 {
    
     //WebApiConfig.Register(config);
     //appBuilder.UseWebApi(config);
     appBuilder.UseCors(CorsOptions.AllowAll);
     appBuilder.UseNinjectMiddleware(NinjectWebCommon.CreateKernel).UseNinjectWebApi(WebApiConfig.Register());
 }
开发者ID:slavasubot,项目名称:Market.Web,代码行数:8,代码来源:Startup.cs

示例13: ConfigureAuth

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        public void ConfigureAuth(IAppBuilder app)
        {
            ConfigureAuth(app);

            var kernel = new StandardKernel();
            kernel.Load(Assembly.GetExecutingAssembly());
            kernel.Bind<IUserIdProvider>().To<AspNetUserIdProvider>();
            kernel.Bind<IOnlineShopData>().To<OnlineShopData>();
            kernel.Bind<DbContext>().To<OnlineShopContext>();

            var httpConfig = new HttpConfiguration();
            WebApiConfig.Register(httpConfig);
            app.UseNinjectMiddleware(() => kernel)
                .UseNinjectWebApi(httpConfig);

            // Configure the db context and user manager to use a single instance per request
            app.CreatePerOwinContext(OnlineShopContext.Create);
            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Configure the application for OAuth based flow
            PublicClientId = "self";
            OAuthOptions = new OAuthAuthorizationServerOptions
            {
                TokenEndpointPath = new PathString("/Token"),
                Provider = new ApplicationOAuthProvider(PublicClientId),
                AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                // In production mode set AllowInsecureHttp = false
                AllowInsecureHttp = true
            };

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //    consumerKey: "",
            //    consumerSecret: "");

            //app.UseFacebookAuthentication(
            //    appId: "",
            //    appSecret: "");

            //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            //{
            //    ClientId = "",
            //    ClientSecret = ""
            //});
        }
开发者ID:nok32,项目名称:SoftUni,代码行数:59,代码来源:Startup.Auth.cs

示例14: Configuration

        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            WebApiConfig.Register(config);
            MappingConfig.RegisterMappings();

            app.UseNinjectMiddleware(() => NinjectConfig.CreateKernel.Value);
            app.UseNinjectWebApi(config);
        }
开发者ID:RuzmanovDev,项目名称:TelerikAcademy,代码行数:9,代码来源:Startup.cs

示例15: Configuration

        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            WebApiConfig.Register(config);

            config.EnableSwagger(c => c.SingleApiVersion("v1", "BigFoodieMealsAPI"))
                .EnableSwaggerUi();

            app.UseNinjectMiddleware(NinjectKernal.CreateKernel).UseNinjectWebApi(config);
        }
开发者ID:neilbigfoodie,项目名称:BigFoodie-Api,代码行数:10,代码来源:ConfigStartup.cs


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