ASP.NET窗体身份验证Cookie在Safari中未设定 [英] ASP.NET Forms Authentication Cookie not set in Safari

查看:186
本文介绍了ASP.NET窗体身份验证Cookie在Safari中未设定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这暴露了一个名为DoLogin方法的ASP.NET Web服务

I have a ASP.NET Web Service which exposes a method called DoLogin

[WebService(Namespace = "http://rtns.ism.ec/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]    
[ScriptService]
public class UserManagerService : WebServiceBase
{

    [WebMethod(EnableSession=true)]
    [ScriptMethod]
    public ResponseBase<bool> DoLogin(LoginCredentials Credentials)
    {
        Credentials.IpAddress = HttpContext.Current.Request.UserHostAddress;
        Credentials.ServerID = Environment.MachineName;
        Credentials.SystemID = WebConfigurationManager.AppSettings["SYSTEM_ID"];
        Credentials.UserAgent = HttpContext.Current.Request.UserAgent;

        try
        {
            DataResponse<User> resp = UserManager.LoginUser(Credentials);

            if (resp.Code)
            {
                FormsAuthentication.SetAuthCookie(Credentials.Email, true);
                HttpContext.Current.Session.Add(Constants.Identifiers.USER_SESSION_INFO_IDENTIFIER, resp.Data);
            }
            return resp;
        }
        catch (Exception _ex)
        {
            ISM.Essentials.Business.LogManager.SaveLog(_ex);
            return new ResponseBase<bool> { Message = MessageManager.Instance[Constants.Messages.E_GENERIC_FAILURE, Credentials.CultureID] };
        }
    }

}

我有一个JQuery的客户端,这使得电话:

I have a JQuery client, which makes the call:

function loginSubmitHandler() {

    var objeto = {
        Email: $('#txtUser').val(),
        Password: $('#txtPassword').val(),
        CultureID: $('#hddCulture').val()
    };

    utils.startAjaxCall('../Services/UserManagerService.asmx/DoLogin', { Credentials: objeto }, function(data) {

    if (data.d.Code) {
        window.location.replace('home.aspx');
    }
    else
    {
        utils.alert(locals.Information, locals.Accept, data.d.Message);            
    }
    });

    return false;
}

当我与icorrect凭据登录,将出现从服务器发送与该消息的警报。如果我给正确的凭据,页面被重定向到home.aspx

When I log in with icorrect credentials, the alert with the message sent from the server appears. If I give correct credentials, the page is redirected to home.aspx

这code工作100%的罚款,因为在以下浏览器开始时:

This code is working 100% fine since the begining in the following browsers:


  • IE6,7,8,9

  • 的Mozilla

  • IE9的Windows Phone

  • Android 2.3的浏览器

  • 5.1的Safari为Windows

我刚刚拿到了一台Mac(第一次),当我试图访问我的网站,我注意到一个交流中心的行为。我给出正确的登录凭据,我重定向到家里,但FormsAuthentication机制重定向到登录页面。

I've just got a Mac (first ever) and when I tried to access my website, I noticed an extrange behavior. I give correct login credentials, I'm redirected to home, but the FormsAuthentication mechanism redirects back to the login page.

这似乎是从服务器只是忽略验证cookie的转回。

It seems like the Auth cookie returned back from the server is just ignored.

这是不是与跨域饼干一个问题,因为我打电话在同一个Web应用程序/域的Web服务器。

This is not an issue with cross domain cookies, as I'm calling the web server in the same web application/domain.

如何让Safari为Mac接受一个Ajax Web服务调用返回的饼干任何想法?

Any ideas on how to make Safari for Mac to accept the cookies returned in an Ajax Web Service call?

推荐答案

该问题可能是Safari浏览器将不设置非ASCII字符饼干。请尝试使用cookie值EN codeURIComponent()函数。下面是类似的问题的链接:
<一href=\"http://stackoverflow.com/questions/5327341/strange-problem-with-cookies-in-safari-and-asp-net\">Strange在Safari和Asp.net 饼干的问题

The problem might be that safari will not set cookies with non-ASCII characters. Try using encodeURIComponent() function on cookie values. Here is a link with similar problem: Strange problem with cookies in Safari and Asp.net

这篇关于ASP.NET窗体身份验证Cookie在Safari中未设定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆