【问题标题】:Getting .aspauth cookie through https通过 https 获取 .aspauth cookie
【发布时间】:2012-11-07 16:19:15
【问题描述】:

这在 http 上运行良好,但在 https 上不起作用。

private Cookie GetAuthCookie(string user, string pass)
    {
        var http = WebRequest.Create(_baseUrl+"Users/Login") as HttpWebRequest;
        http.AllowAutoRedirect = false;
        http.Method = "POST";
        http.ContentType = "application/x-www-form-urlencoded";
        http.CookieContainer = new CookieContainer();
        var postData = "UserName=" + user + "&Password=" + pass + "&RememberMe=true&RememberMe=false&ReturnUrl=www.google.com";
        byte[] dataBytes = System.Text.Encoding.UTF8.GetBytes(postData);
        http.ContentLength = dataBytes.Length;
        using (var postStream = http.GetRequestStream())
        {
            postStream.Write(dataBytes, 0, dataBytes.Length);
        }
        var httpResponse = http.GetResponse() as HttpWebResponse;
        return httpResponse.Cookies[FormsAuthentication.FormsCookieName];
    }

【问题讨论】:

标签: asp.net authentication cookies https


【解决方案1】:

这可能是一个 SSL 证书问题,您会在通过 WebClient 或 WebRequest 访问 SSL 时看到这一点,具体取决于您的证书颁发者的情况。有关如何解决此问题,请参阅之前的question for details

【讨论】:

    猜你喜欢
    • 2012-04-27
    • 2012-07-23
    • 1970-01-01
    • 2018-12-09
    • 1970-01-01
    • 2011-01-10
    • 2012-02-26
    • 1970-01-01
    • 2011-12-04
    相关资源
    最近更新 更多