I am developing a web application. For the security of user information, I need an https connection. Now I am developing this local. I followed the tutorial: http://weblogs.asp.net/dwahlin/archive/2009/08/25/requiring-ssl-for-asp-net-mvc-controllers.aspx
When I build my project, the page loads, but the url is: http: // ...
In my code, I posted:
[RequiresSSL]
public ActionResult Index()
{
return View(db.Eusers.ToList());
}
code from the site:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace extranet.Helpers
{
public class RequiresSSL: ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
HttpRequestBase req = filterContext.HttpContext.Request;
HttpResponseBase res = filterContext.HttpContext.Response;
if (!req.IsSecureConnection && !req.IsLocal)
{
var builder = new UriBuilder(req.Url)
{
Scheme = Uri.UriSchemeHttps,
Port = 443
};
res.Redirect(builder.Uri.ToString());
}
base.OnActionExecuting(filterContext);
}
}
}
What am I missing that the url is not https based? Is it because I work locally?
Thanks in advance
source
share