Fixed build break and used new pattern for using mvc

This commit is contained in:
David Fowler 2014-04-17 21:21:57 -07:00
parent 3c4a2df2cb
commit f258b008fa
2 changed files with 15 additions and 22 deletions

View File

@ -23,18 +23,15 @@ using System.IO;
public class Startup
{
private static void ConfigureServices(ServiceCollection services)
{
services.AddInstance<ILoggerFactory>(new NullLoggerFactory());
services.AddMvc();
services.AddInstance<UserManager<ApplicationUser>>(new UserManager<ApplicationUser>(new InMemoryUserStore<ApplicationUser>()));
services.AddInstance<RoleManager<IdentityRole>>(new RoleManager<IdentityRole>(new InMemoryRoleStore<IdentityRole>()));
}
public void Configuration(IBuilder app)
{
app.UseContainer(ConfigureServices);
app.UseServices(services =>
{
services.AddInstance<ILoggerFactory>(new NullLoggerFactory());
services.AddMvc();
services.AddInstance<UserManager<ApplicationUser>>(new UserManager<ApplicationUser>(new InMemoryUserStore<ApplicationUser>()));
services.AddInstance<RoleManager<IdentityRole>>(new RoleManager<IdentityRole>(new InMemoryRoleStore<IdentityRole>()));
});
//ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
app.UseErrorPage(ErrorPageOptions.ShowAll);
@ -47,20 +44,16 @@ public class Startup
LoginPath = new PathString("/Account/Login")
});
var routes = new RouteCollection()
app.UseMvc(routes =>
{
DefaultHandler = new MvcRouteHandler(),
};
routes.MapRoute(
"{controller}/{action}",
new { controller = "Home", action = "Index" });
routes.MapRoute(
"{controller}/{action}",
new { controller = "Home", action = "Index" });
routes.MapRoute(
"{controller}",
new { controller = "Home" });
app.UseRouter(routes);
routes.MapRoute(
"{controller}",
new { controller = "Home" });
});
SampleData.InitializeMusicStoreDatabaseAsync().Wait();
CreateAdminUser(app.ServiceProvider);