How to use https in c #?

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()
    {
        //var model = Adapter.EuserRepository.GetAll();

        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;

            //Check if we're secure or not and if we're on the local box
            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

+5
source share
2 answers

, : && !req.IsLocal. , . , HTTPS , .

+3

, 401 - , https

. , https, .

0

All Articles