Guest User

Untitled

a guest
Apr 24th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. app.UseDefaultFiles();
  2. app.UseStaticFiles();
  3. app.UseIdentity();
  4.  
  5. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
  6. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  7. loggerFactory.AddDebug();
  8.  
  9. //add NLog to ASP.NET Core
  10. //loggerFactory.AddNLog();
  11.  
  12. ////add NLog.Web
  13. //app.AddNLogWeb();
  14.  
  15. //needed for non-NETSTANDARD platforms: configure nlog.config in your project root
  16. //env.ConfigureNLog("nlog.config");
  17.  
  18. if (env.IsDevelopment()) {
  19. app.UseDeveloperExceptionPage();
  20. app.UseDatabaseErrorPage();
  21. app.UseBrowserLink();
  22. } else {
  23. app.UseExceptionHandler("/Home/Error");
  24. }
  25.  
  26. app.UseDefaultFiles();
  27. app.UseStaticFiles();
  28. app.UseIdentity();
  29.  
  30. // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
  31. app.UseMvcWithDefaultRoute();
  32. //app.UseMvc(routes => {
  33. // routes.MapRoute(
  34. // name: "default",
  35. // template: "{controller=Home}/{action=Index}/{id?}");
  36. //});
  37.  
  38. // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
  39. try {
  40. using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
  41. .CreateScope()) {
  42. serviceScope.ServiceProvider.GetService<ChurBaseContext>()
  43. .Database.Migrate();
  44.  
  45. var userManager = serviceScope.ServiceProvider.GetService<UserManager<ChurchMember>>();
  46. var roleManager = serviceScope.ServiceProvider.GetService<RoleManager<IdentityRole>>();
  47.  
  48. serviceScope.ServiceProvider.GetService<ChurBaseContext>().EnsureSeedData(userManager, roleManager);
  49. }
  50. } catch { }
  51. }
  52.  
  53. app.UseMvcWithDefaultRoute(); //in startup.cs
  54.  
  55. app.UseMvc(routes =>
  56. {
  57. routes.MapRoute(
  58. name: "default",
  59. template: "{controller}/{action}/{id?}",
  60. defaults: new { controller = "Home", action = "Index" });
  61. });
  62.  
  63. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  64. {
  65. ......
  66.  
  67. app.UseStaticFiles();
  68.  
  69. app.UseMvc(routes =>
  70. {
  71. routes.MapRoute(
  72. name: "default",
  73. template: "{controller=Home}/{action=Index}/{id?}");
  74. });
  75. }
  76.  
  77. app.UseMvcWithDefaultRoute();
  78.  
  79. app.Use(async (context, next) =>
  80. {
  81. // some custom magic
  82.  
  83. await next();// don't forget this
  84. });
  85.  
  86. app.UseMvc(routes =>
  87. {
  88. routes.MapRoute(
  89. name: "default",
  90. template: "{controller=Home}/{action=Index}/{id?}");
  91. });
Add Comment
Please, Sign In to add comment