In Visual Studio 2015, when we select the MVC6 web application, the Properties window contains no SSL Enabled property.
So what is the correct way to run a MVC6 application in SSL?
Since we can create pure Html + JavaScript site with the empty MVC 6 Application, can we enable SSL without using RequireHttpsAttribute
that only comes with MVC?
In your Startup.cs file options.Filters.Add(new RequireHttpsAttribute());
public class Startup
{
public IConfiguration Configuration { get; set; }
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
.......
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<MvcOptions>(options =>
{
.....
options.Filters.Add(new RequireHttpsAttribute());
});
}
public void Configure(IApplicationBuilder app)
{
app.UseMvc(routes =>
{
routes.MapRoute(
"default",
"{controller)/{action}",
new { controller = "Home", action = "Index" }
);
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With