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": "Server=**********;Database=Customers;User Id=sa;password=*******" | |
} |
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
public IConfigurationRoot ConfigurationRoot { get; set; } | |
public static string ConnectionString { get; private set; } | |
public Startup(IConfiguration config,IWebHostEnvironment env) | |
{ | |
ConfigurationRoot = new ConfigurationBuilder() | |
.SetBasePath(env.ContentRootPath) | |
.AddJsonFile("appSettings.json") | |
.Build(); |
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
public class HomeController : Controller | |
{ | |
private readonly ILogger<HomeController> _logger; | |
private IHostingEnvironment _environment; | |
public HomeController(ILogger<HomeController> logger, IHostingEnvironment environment) | |
{ | |
_logger = logger; | |
_environment = environment; | |
} |
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
public class HomeController : Controller | |
{ | |
private readonly ILogger<HomeController> _logger; | |
private IWebHostEnvironment _environment; | |
public HomeController(ILogger<HomeController> logger, IWebHostEnvironment environment) | |
{ | |
_logger = logger; | |
_environment = environment; | |
} | |
public IActionResult Index() |
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
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
app.Run(Mymiddleware); | |
app.Run(async (context) => | |
{ |
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
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
app.Use(async (context, next) => | |
{ | |
await context.Response.WriteAsync("Hello World check from Use method!"); |
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
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
app.Use(async (context, next) => | |
{ | |
await context.Response.WriteAsync("Hello World check from Use method!"); |
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
DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions(); | |
defaultFilesOptions.DefaultFileNames.Clear(); | |
defaultFilesOptions.DefaultFileNames.Add("custom.html"); | |
// This is use for Default Files Middleware | |
app.UseDefaultFiles(defaultFilesOptions); |
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
FileServerOptions fileServerOptions = new FileServerOptions(); | |
fileServerOptions.DefaultFilesOptions.DefaultFileNames.Clear(); | |
fileServerOptions.DefaultFilesOptions.DefaultFileNames.Add("custom.html"); | |
app.UseFileServer(fileServerOptions); |
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
public static void Main(string[] args) | |
{ | |
var host = new WebHostBuilder() | |
.UseKestrel() | |
.UseWebRoot("myCustomRoot") | |
.UseContentRoot(Directory.GetCurrentDirectory()) | |
.UseIISIntegration() | |
.UseStartup<Startup>() | |
.Build(); | |
host.Run(); |
OlderNewer