Guest User

Untitled

a guest
Mar 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. <PackageReference Include="Microsoft.AspNetCore" Version="2.0.2" />
  2. <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" />
  3. <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.3" PrivateAssets="All" />
  4. <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.2" />
  5. <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.2" />
  6.  
  7. <PackageReference Include="Microsoft.SqlServer.Types" Version="11.0.2" />
  8. <PackageReference Include="FluentValidation.AspNetCore" Version="7.5.2" />
  9.  
  10. public class Program
  11. {
  12. public static void Main(string[] args)
  13. {
  14. BuildWebHost(args).Run();
  15. }
  16.  
  17. public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup<Startup>().Build();
  18. }
  19.  
  20. public IConfiguration Configuration { get; }
  21.  
  22. public Startup(IConfiguration configuration)
  23. {
  24. Configuration = configuration;
  25. }
  26.  
  27. // This method gets called by the runtime. Use this method to add services to the container.
  28. public void ConfigureServices(IServiceCollection services)
  29. {
  30. // Load Configuration from appsettings.json
  31. services.Configure<IdentityServerSettings>(Configuration.GetSection("IdentityServerSettings"));
  32. services.AddOptions();
  33.  
  34. var identityServerOptions = serviceProvider.GetService<IOptions<IdentityServerSettings>>().Value;
  35. services.AddMvc(o =>
  36. {
  37. if (identityServerOptions.EnableSSL)
  38. o.Filters.Add(new RequireHttpsAttribute());
  39. });
  40.  
  41. services.AddAuthentication("Bearer").AddIdentityServerAuthentication(opt =>
  42. {
  43. opt.Authority = identityServerOptions.Authority;
  44. opt.RequireHttpsMetadata = identityServerOptions.EnableSSL;
  45. opt.ApiName = identityServerOptions.ApiName;
  46. });
  47. }
  48.  
  49.  
  50. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  51. {
  52. #region Identity Server Config
  53. // Setup Identity Server Options for this API -
  54. app.UseAuthentication();
  55.  
  56. #endregion
  57.  
  58. if (env.IsDevelopment())
  59. {
  60. app.UseDeveloperExceptionPage();
  61. app.UseBrowserLink();
  62. }
  63. else
  64. {
  65. app.UseExceptionHandler("/Home/Error");
  66. }
  67.  
  68. app.UseStaticFiles();
  69.  
  70. // tried this
  71. app.UseMvc();
  72.  
  73. // and this
  74. //app.UseMvcWithDefaultRoute();
  75.  
  76. // and this
  77. //app.UseMvc(routes =>
  78. //{
  79. // routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
  80. //});
  81. }
  82.  
  83. app.UseMvc(routes =>
  84. {
  85. routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
  86. });
Add Comment
Please, Sign In to add comment