Guest User

Untitled

a guest
Nov 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public void ConfigureServices(IServiceCollection services)
  2. {
  3. services.AddScoped<HeroesRepository, HeroesRepository>();
  4.  
  5. #if DEBUG
  6. services.AddCors(options =>
  7. {
  8. options.AddPolicy(
  9. "AllowSpecificOrigin",
  10. builder => builder
  11. .AllowAnyOrigin()
  12. .AllowAnyHeader()
  13. .AllowAnyMethod()
  14. );
  15. });
  16. #endif
  17. services.AddMvc();
  18. }
  19.  
  20. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  21. {
  22. if (env.IsDevelopment())
  23. {
  24. app.UseDeveloperExceptionPage();
  25. }
  26. else
  27. {
  28. app.UseExceptionHandler("/Home/Error");
  29. }
  30.  
  31. #if DEBUG
  32. app.UseCors("AllowSpecificOrigin");
  33. #endif
  34. app.UseStaticFiles();
  35.  
  36. app.UseMvc(routes =>
  37. {
  38. routes.MapRoute(
  39. name: "default",
  40. template: "{controller=Home}/{action=Index}/{id?}");
  41.  
  42. // Will make angular page bookmarkable
  43. routes.MapSpaFallbackRoute(
  44. name: "spa-fallback",
  45. defaults: new { controller = "Home", action = "Index" });
  46. });
  47.  
  48. }
Add Comment
Please, Sign In to add comment