本文整理汇总了C#中IAppBuilder.UseNinjectWebApi方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseNinjectWebApi方法的具体用法?C# IAppBuilder.UseNinjectWebApi怎么用?C# IAppBuilder.UseNinjectWebApi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseNinjectWebApi方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: Configuration
public void Configuration(IAppBuilder app)
{
var config = CreateHttpConfiguration();
app.UseNinjectMiddleware(Ninject.CreateKernel);
app.UseNinjectWebApi(config);
}
示例4: Configuration
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
WebApiConfig.Register(config);
app.UseNinjectMiddleware(() => NinjectConfig.CreateKernel.Value);
app.UseNinjectWebApi(config);
}
示例5: Configuration
public void Configuration(IAppBuilder appBuilder)
{
var config = new HttpConfiguration();
WebApiConfig.Register(config);
appBuilder.UseNinjectMiddleware(CreateKernel);
appBuilder.UseNinjectWebApi(config);
}
示例6: 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));
}
示例7: Configuration
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
ConfigureOAuth(app);
WebApiConfig.Register(config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseNinjectMiddleware(CreateKernel);
app.UseNinjectWebApi(config);
}
示例8: ConfigureNinject
public IKernel ConfigureNinject(IAppBuilder app, HttpConfiguration httpConfig)
{
var kernel = CreateKernel(app);
RegisterServiceLocator(kernel);
app.UseNinjectMiddleware(() => kernel);
app.UseNinjectWebApi(httpConfig);
return kernel;
}
示例9: Configure
public void Configure(IAppBuilder appBuilder, IKernel kernel)
{
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
config.MapDefinedRoutes();
appBuilder.UseNinjectMiddleware(() => kernel);
appBuilder.UseNinjectWebApi(config);
}
示例10: Configuration
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
var config = new HttpConfiguration();
WebApiConfig.Register(config);
app.UseNinjectMiddleware(() => NinjectConfig.CreateKernel.Value);
app.UseNinjectWebApi(config);
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
}
示例11: ConfigureWebApi
public void ConfigureWebApi(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
jsonFormatter.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
app.UseNinjectWebApi(config);
}
示例12: Configuration
/// <summary>
/// Creates a configuration.
/// </summary>
/// <param name="app">
/// The app.
/// </param>
public void Configuration(IAppBuilder app)
{
var webApiConfiguration = new HttpConfiguration();
webApiConfiguration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}",
defaults: new { id = RouteParameter.Optional, controller = "values" });
app.UseNinjectMiddleware(CreateKernel);
app.UseNinjectWebApi(webApiConfiguration);
}
示例13: Configuration
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Formatters.Clear();
config.Formatters.Add(new JsonMediaTypeFormatter());
config.MapHttpAttributeRoutes();
config.EnsureInitialized();
app.UseNinjectMiddleware(CreateKernel);
app.UseNinjectWebApi(config);
}
示例14: Configure
public void Configure(IAppBuilder appBuilder, IKernel kernel)
{
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
config.MapDefinedRoutes();
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
log4net.Config.XmlConfigurator.Configure();
appBuilder.UseNinjectMiddleware(() => kernel);
appBuilder.UseNinjectWebApi(config);
}
示例15: Configuration
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
ConfigureAuth(app);
var config = new HttpConfiguration();
WebApiConfig.Register(config);
DatabaseConfig.Initialize();
MappingConfig.Initialize();
app.UseNinjectMiddleware(() => NinjectConfig.CreateKernel.Value);
app.UseNinjectWebApi(config);
}