// This method gets called by the runtime. public void ConfigureServices(IServiceCollection services) { //EF7 setup var connection = Configuration.Get("Data:DefaultConnection:Connectionstring"); //from config.json services.AddEntityFramework() .AddSqlServer() .AddDbContext <lovelyjubblyMVC6WebApiContext>(options => options.UseSqlServer(connection)); // Add MVC services to the services container. services.AddMvc(); //Add Cors support to the service services.AddCors(); var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); policy.Headers.Add("*"); policy.Methods.Add("*"); policy.Origins.Add("*"); policy.SupportsCredentials = true; services.ConfigureCors(x => x.AddPolicy("mypolicy", policy)); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); }
// This method gets called by a runtime. // Use this method to add services to the container public void ConfigureServices(IServiceCollection services) { services.AddInstance<IConfiguration>(Configuration); services.AddCustomBindings(Configuration); services.AddMvc().Configure<MvcOptions>(options => { options.OutputFormatters.OfType<JsonOutputFormatter>() .First() .SerializerSettings .ContractResolver = new CamelCasePropertyNamesContractResolver(); }); // CORS services.AddCors(); var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); policy.Headers.Add("*"); policy.Methods.Add("*"); policy.Origins.Add("*"); policy.SupportsCredentials = true; services.ConfigureCors(x => x.AddPolicy("mypolicy", policy)); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); }
// This method gets called by a runtime. // Use this method to add services to the container public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); //Add Cors support to the service services.AddCors(); var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); policy.Headers.Add("*"); policy.Methods.Add("*"); policy.Origins.Add("*"); policy.SupportsCredentials = true; services.ConfigureCors(x=>x.AddPolicy("mypolicy", policy)); }
// This method gets called by a runtime. // Use this method to add services to the container public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); //Add Cors support to the service services.AddCors(); var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); policy.Headers.Add("*"); policy.Methods.Add("*"); policy.Origins.Add("*"); policy.SupportsCredentials = true; services.ConfigureCors(x => x.AddPolicy("mypolicy", policy)); }
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddDataProtection(); services.AddMvc() .AddMvcOptions(options => { var jsonOutputFormatter = new JsonOutputFormatter(); jsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.OutputFormatters.Insert(0, jsonOutputFormatter); }); services.AddCors(); var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); policy.Headers.Add("*"); policy.Methods.Add("*"); policy.Origins.Add("*"); policy.SupportsCredentials = true; services.AddCors(o => o.AddPolicy("mypolicy", policy)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add Entity Framework services to the services container. services.AddEntityFramework() .AddSqlServer() .AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])); // Add Identity services to the services container. services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); // Configure the options for the authentication middleware. // You can add options for Google, Twitter and other middleware as shown below. // For more information see http://go.microsoft.com/fwlink/?LinkID=532715 services.Configure<FacebookAuthenticationOptions>(options => { options.AppId = Configuration["Authentication:Facebook:AppId"]; options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; }); services.Configure<MicrosoftAccountAuthenticationOptions>(options => { options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"]; options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"]; }); // Add MVC services to the services container. services.AddMvc(); services.AddCors(); var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); policy.Headers.Add("*"); policy.Methods.Add("*"); policy.Origins.Add("*"); policy.SupportsCredentials = true; services.ConfigureCors(x => x.AddPolicy("mypolicy", policy)); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); // Register application services. services.AddTransient<IEmailSender, AuthMessageSender>(); services.AddTransient<ISmsSender, AuthMessageSender>(); services.AddTransient<IAsyncDataRetrievalHelper, AsyncDataRetrievalHelper>(); services.AddTransient<IChallongeApiUrlHelper, ChallongeApiUrlHelper>(); }
// This method gets called by the runtime. public void ConfigureServices(IServiceCollection services) { //EF7 setup var connection = Configuration.Get("Data:DefaultConnection:Connectionstring"); //from config.json services.AddEntityFramework() .AddSqlServer() .AddDbContext<lovelyjubblyMVC6WebApiContext>(options => options.UseSqlServer(connection)); // Add MVC services to the services container. services.AddMvc(); //Add Cors support to the service services.AddCors(); var policy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); policy.Headers.Add("*"); policy.Methods.Add("*"); policy.Origins.Add("*"); policy.SupportsCredentials = true; services.ConfigureCors(x => x.AddPolicy("mypolicy", policy)); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add Entity Framework services to the services container. services.AddEntityFramework() .AddSqlServer() .AddDbContext<ApplicationContext>(options => options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])); services.AddIdentity<ApplicationUser, ApplicationRole>( options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 3; options.Password.RequireNonLetterOrDigit = false; options.Password.RequireUppercase = false; options.Password.RequireLowercase = false; }) .AddEntityFrameworkStores<ApplicationContext,int>() .AddDefaultTokenProviders(); // Configure the options for the authentication middleware. // You can add options for Google, Twitter and other middleware as shown below. // For more information see http://go.microsoft.com/fwlink/?LinkID=532715 services.Configure<FacebookAuthenticationOptions>(options => { options.AppId = Configuration["Authentication:Facebook:AppId"]; options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; }); services.Configure<MicrosoftAccountAuthenticationOptions>(options => { options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"]; options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"]; }); services.ConfigureIdentityApplicationCookie(options => { options.LoginPath = "/Error/AuthenticationFailed"; options.AccessDeniedPath = "/Error/AccessDenied"; }); // Add MVC services to the services container. services.AddMvc(); // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. // services.AddWebApiConventions(); // Register application services. var corsPolicy = new Microsoft.AspNet.Cors.Core.CorsPolicy(); corsPolicy.Headers.Add("*"); corsPolicy.Methods.Add("*"); corsPolicy.Origins.Add("*"); corsPolicy.SupportsCredentials = true; services.ConfigureCors(x => x.AddPolicy("CustomPolicy", corsPolicy)); services.AddCors(); services.AddMvc(); services.AddTransient<IRepository<Movie>, GenericRepository<Movie>>() .AddTransient<IRepository<Actor>, GenericRepository<Actor>>() .AddTransient<IRepository<Cinema>, GenericRepository<Cinema>>() .AddTransient<IUnitOfWork, UnitOfWork>(); services.AddTransient<IEmailSender, AuthMessageSender>(); services.AddTransient<ISmsSender, AuthMessageSender>(); ConfigurePolicies(services); }