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