8
HTTPS我如何試圖做到這一點:在啓動如何啓用mvc6
1設置過濾器:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
//...
services.AddMvc();
services.Configure<MvcOptions>(options =>
{
options.Filters.Add(new RequireHttpsAttribute());
});
2 - 集[RequireHttps]在cotroler
[RequireHttps]
public class HomeController : BaseController
{
public ViewResult Index()
{
return View();
}
}
3 - add in project.json
"kestrel": "Microsoft.AspNet.Hosting --server=Microsoft.AspNet.Server.Kestrel --server.urls=https://localhost:1234"
而且還沒有工作G。 我做錯了什麼?
此問題適用於MVC6。在這種情況下,您添加了儘可能重複的答案沒有幫助。 – Raskolnikov