Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <PackageReference Include="Microsoft.AspNetCore" Version="2.0.2" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.3" PrivateAssets="All" />
- <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.2" />
- <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.2" />
- <PackageReference Include="Microsoft.SqlServer.Types" Version="11.0.2" />
- <PackageReference Include="FluentValidation.AspNetCore" Version="7.5.2" />
- public class Program
- {
- public static void Main(string[] args)
- {
- BuildWebHost(args).Run();
- }
- public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup<Startup>().Build();
- }
- public IConfiguration Configuration { get; }
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- // Load Configuration from appsettings.json
- services.Configure<IdentityServerSettings>(Configuration.GetSection("IdentityServerSettings"));
- services.AddOptions();
- var identityServerOptions = serviceProvider.GetService<IOptions<IdentityServerSettings>>().Value;
- services.AddMvc(o =>
- {
- if (identityServerOptions.EnableSSL)
- o.Filters.Add(new RequireHttpsAttribute());
- });
- services.AddAuthentication("Bearer").AddIdentityServerAuthentication(opt =>
- {
- opt.Authority = identityServerOptions.Authority;
- opt.RequireHttpsMetadata = identityServerOptions.EnableSSL;
- opt.ApiName = identityServerOptions.ApiName;
- });
- }
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
- #region Identity Server Config
- // Setup Identity Server Options for this API -
- app.UseAuthentication();
- #endregion
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- app.UseBrowserLink();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- }
- app.UseStaticFiles();
- // tried this
- app.UseMvc();
- // and this
- //app.UseMvcWithDefaultRoute();
- // and this
- //app.UseMvc(routes =>
- //{
- // routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
- //});
- }
- app.UseMvc(routes =>
- {
- routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
- });
Add Comment
Please, Sign In to add comment