How to use RequireHttps in ASP.NET MVC ?
ASP.NET MVC has an attribute called RequireHttps which can be used to forces an unsecure HTTP request to pass through Https.
How to use RequireHttps in ASP.NET MVC ?
You can use RequireHttps by just placing the RequireHttps attribute on top of the Action Method in the Controller like an sample shown below.
C#
x
31
31
1
using System;
2
3
using System.Collections.Generic;
4
5
using System.Linq;
6
7
using System.Web;
8
9
using System.Web.Mvc;
10
11
namespace MvcApplication1.Controllers
12
13
{
14
15
public class EmployeeController : Controller
16
17
{
18
19
[RequireHttps]
20
21
public ActionResult Index()
22
23
{
24
25
return View();
26
27
}
28
29
}
30
31
}
Leave Your Comment