// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ProteinsContext proteinsContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } // 建立資料庫 proteinsContext.Database.EnsureCreated(); app.UseMvc(); app.UseMvcWithDefaultRoute(); app.UseHttpsRedirection(); #region 使用SwaggerUI app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Dinner API V1"); }); #endregion }
public ValuesController(ProteinsContext proteinContext, IHttpContextAccessor httpContextAccessor) { _proteinContext = proteinContext; _httpContextAccessor = httpContextAccessor; //_httpContextAccessor.HttpContext.Request.Cookies }