Professional Documents
Culture Documents
Dependency injection
Vad vi går igenom
Vad är Dependency Injection?
Services
Middleware
Konfigurationsfiler
Vad är tanken med Core?
builder.Services.AddDbContext<PersonDBContext>(options =>
options.UseSqlServer(connectionstring));
Middleware
app.UseStaticFiles();
app.UseIdentity();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
Konfigurationsfiler
"ConnectionStrings": {
"Default": ”Server=localhost;Database=MyDB;Trusted_Connection=True"
},
"MyConfig": {
”Myvalue": ”123" }
string connectionstring =
builder.Configuration.GetConnectionString(”Default");
Länkar
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection
https://medium.com/volosoft/asp-net-core-dependency-injection-best-practices-tips-
tricks-c6e9c67f9d96
https://www.codementor.io/@mrfojo/c-with-dependency-injection-k2qfxbb8q
https://www.dotnettricks.com/learn/dependencyinjection/implementation-asp-net-core-mvc
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration