Skip to content

Instantly share code, notes, and snippets.

@AndyButland
Created September 26, 2016 09:12
Show Gist options
  • Save AndyButland/ff1c12e21a66236af0e66fe62861ef99 to your computer and use it in GitHub Desktop.
Save AndyButland/ff1c12e21a66236af0e66fe62861ef99 to your computer and use it in GitHub Desktop.
using System.Reflection;
using AutoMapper;
using MediatR;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
var connection = @"Server=.\SQLEXPRESS2012;Database=AspNetCoreToDo;Trusted_Connection=True;";
services.AddDbContext<ToDoContext>(options =>
options.UseSqlServer(connection));
services.AddSession();
services.AddMvc();
services.AddAutoMapper(GetExecutingAssembly());
services.AddMediatR(GetExecutingAssembly());
}
public void Configure(IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
private static Assembly GetExecutingAssembly()
{
return typeof(Startup).GetTypeInfo().Assembly;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment