本文整理汇总了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>"
// );
}
示例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);
}
示例3: Configuration
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(GlobalConfiguration.Configuration);
}
示例4: Configuration
public void Configuration(IAppBuilder app)
{
var config = CreateHttpConfiguration();
app.UseNinjectMiddleware(Ninject.CreateKernel);
app.UseNinjectWebApi(config);
}
示例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);
}
示例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);
}
示例7: Configuration
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
ConfigureAuth(app);
app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(GlobalConfiguration.Configuration);
}
示例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"}
})
}
});
}
示例9: Configuration
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
ConfigureOAuth(app);
WebApiConfig.Register(config);
app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(config);
}
示例10: Configuration
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
WebApiConfig.Register(config);
app.UseNinjectMiddleware(() => kernel.Value).UseNinjectWebApi(config);
}
示例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));
}
示例12: Configuration
public void Configuration(IAppBuilder appBuilder)
{
//WebApiConfig.Register(config);
//appBuilder.UseWebApi(config);
appBuilder.UseCors(CorsOptions.AllowAll);
appBuilder.UseNinjectMiddleware(NinjectWebCommon.CreateKernel).UseNinjectWebApi(WebApiConfig.Register());
}
示例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 = ""
//});
}
示例14: Configuration
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
WebApiConfig.Register(config);
MappingConfig.RegisterMappings();
app.UseNinjectMiddleware(() => NinjectConfig.CreateKernel.Value);
app.UseNinjectWebApi(config);
}
示例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);
}