// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddScoped <IProductRepository, SqlProductRepository>(); services.AddScoped <ISaleRepository, SqlSaleRepository>(); services.AddScoped <ISaledetailRepository, SqlSaledetailRepository>(); services.AddScoped <IAdminRepository, SqlAdminRepository>(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o => { //登录路径:这是当用户试图访问资源但未经过身份验证时,程序将会将请求重定向到这个相对路径 o.LoginPath = new PathString("/Account/Login"); //禁止访问路径:当用户试图访问资源时,但未通过该资源的任何授权策略,请求将被重定向到这个相对路径。 o.AccessDeniedPath = new PathString("/Home/Index"); }); //MySql string connectionsString = _configuration.GetConnectionString("MySqlConnection"); services.AddDbContextPool <jquerytestContext>(options => options.UseMySql(connectionsString, MySqlOptions => MySqlOptions.ServerVersion("8.0.21-mysql"))); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContextPool <ApplicationContext>(options => options .UseMySql(Configuration.GetConnectionString("ApplicationDatabase"), MySqlOptions => MySqlOptions .ServerVersion(new Version(8, 0, 20), ServerType.MySql) )); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContextPool <TodoContext>(opt => opt .UseMySql("Server=localhost;Database=todo;User=root;Convert Zero Datetime=True", MySqlOptions => MySqlOptions .ServerVersion(new Version(10, 4, 6), ServerType.MariaDb) ) ); services.AddCors(opt => opt.AddPolicy("AllowAll", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader())); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(Options => { Options.AddPolicy("AllowAll", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); }); // services.AddDbContext<TodoContext>(opt => // opt.UseInMemoryDatabase("TodoList")); services.AddDbContext <TodoContext>( opt => opt.UseMySql("Server=localhost;Database=Todoef;user=root;", MySqlOptions => { MySqlOptions.ServerVersion(new Version(10, 1, 38), ServerType.MariaDb); }) ); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContextPool <MyDbContext>(options => { options.UseMySql( Configuration["Data:WordCard:ConnectionString"], MySqlOptions => { MySqlOptions.ServerVersion(new Version(10, 1, 38), ServerType.MariaDb); } ); }); services.AddTransient <IWordRepository, EFWordRepo>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ); services.AddDbContextPool <PetshopDBContext> (options => options .UseMySql("Server=veterinariadb.c5zn0tpz4e5k.us-east-2.rds.amazonaws.com;Port=3306;Database=DBPetshop;User=admin;Password=Moviles123;" , MySqlOptions => MySqlOptions.ServerVersion(new Version(10, 2, 21), ServerType.MariaDb))); }
public void ConfigureServices(IServiceCollection services) { // Add framework services. services // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ .AddControllers() .AddNewtonsoftJson(opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); opts.SerializerSettings.Converters.Add(new StringEnumConverter { NamingStrategy = new CamelCaseNamingStrategy() }); }); services .AddSwaggerGen(c => { c.SwaggerDoc("0.1", new OpenApiInfo { Title = "登記・供託オンライン申請システムAPI", Description = "登記・供託オンライン申請システムAPI (ASP.NET Core 3.1)", TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), Contact = new OpenApiContact { Name = "OpenAPI-Generator Contributors", Url = new Uri("https://github.com/openapitools/openapi-generator"), Email = "" }, License = new OpenApiLicense { Name = "NoLicense", Url = new Uri("http://localhost") }, Version = "0.1", }); c.CustomSchemaIds(type => type.FriendlyId(true)); c.DescribeAllEnumsAsStrings(); c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml"); // Sets the basePath property in the Swagger document generated c.DocumentFilter <BasePathFilter>("/rs/api/v1"); // Include DataAnnotation attributes on Controller Action parameters as Swagger validation rules (e.g required, pattern, ..) // Use [ValidateModelState] on Actions to actually validate it in C# as well! c.OperationFilter <GeneratePathParamsValidationFilter>(); }); services .AddSwaggerGenNewtonsoftSupport(); //セッションサービス services.AddDistributedMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(1); options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; options.Cookie.SameSite = SameSiteMode.Lax; }); //シミュレータ設定のDBのコンテキスト services.AddDbContext <SimLineDbContext>(options => options .UseMySql( Configuration.GetConnectionString("SimLineDbConnectionString"), MySqlOptions => MySqlOptions.ServerVersion(new Version(10, 5, 4), ServerType.MariaDb) ) ); //申請者情報取得サービス登録 services.AddScoped <IShinseishaService, ShinseishaService>(); //シミュレータ設定取得サービス登録 services.AddScoped <ISMConfigService, SMConfigService>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContextPool <MvcEpfContext>(options => options.UseMySql(Configuration.GetConnectionString("connect"), MySqlOptions => MySqlOptions. ServerVersion(new Version(8, 0, 21), Pomelo.EntityFrameworkCore.MySql.Infrastructure.ServerType.MySql))); services.AddControllersWithViews(); }