This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using BooksWebApi.Data; | |
using BooksWebApi.Entities; | |
using Microsoft.AspNetCore; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Identity; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
namespace BooksWebApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ConnectionStrings": { | |
"DefaultConnection": "Data Source=HOST\\SQLEXPRESS;Initial Catalog=DbBooksCat;User ID=user;Password=YourPaasowrd;", | |
"AzureConnection": "Server=tcp:sqlserver.database.windows.net,1433;Initial Catalog=booksdb;Persist Security Info=False;User ID=admin;Password=YourPassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" | |
}, | |
"Logging": { | |
"IncludeScopes": false, | |
"Debug": { | |
"LogLevel": { | |
"Default": "Debug" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") | |
{ | |
services.AddDbContext<BooksCatalogDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); | |
} | |
else | |
{ | |
services.AddDbContext<BooksCatalogDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("AzureConnection"))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
app.UseDatabaseErrorPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Error"); | |
} | |
app.UseAuthentication(); |
OlderNewer