tho*_*lau 5 c# asp.net-mvc https asp.net-mvc-4
我正在开发一个Web应用程序.为了用户信息的安全,我需要一个https连接.我现在正在开发这个地方.我已按照以下教程:http://weblogs.asp.net/dwahlin/archive/2009/08/25/requiring-ssl-for-asp-net-mvc-controllers.aspx
当我构建我的项目页面加载但网址是:http:// ...
在我的代码我已经放置:
    [RequiresSSL]
    public ActionResult Index()
    {
        //var model = Adapter.EuserRepository.GetAll();
        return View(db.Eusers.ToList());
    }
网站代码:
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);
        }
    }
}
我错过了什么网址不是基于https的?这是因为我在当地工作吗?
提前致谢
| 归档时间: | 
 | 
| 查看次数: | 611 次 | 
| 最近记录: |