2

Json形式のAjaxによって.aspxページでuserNameとPass to webmethodを渡しました。今、ユーザーを認証し、ユーザーを同じページにリダイレクトし、LoginViewをLogedIn Stateで更新します。

どうすればできますか?ここに私のWebメソッドがあります

[WebMethod]
    // [ [System.Web.Script.Services.ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet=false)]
    public static void login(object myData)
    {

        JavaScriptSerializer js = new JavaScriptSerializer();
        List<nameVal> myfrm = js.Deserialize<List<nameVal>>(myData.ToString());
      //  MembershipUser u = Membership.GetUser(myfrm.SingleOrDefault(rs=>rs.name=="userName").value);

        if (  Membership.ValidateUser(myfrm[0].value,myfrm[1].value))
        {
            FormsAuthentication.Authenticate(myfrm[0].value, myfrm[1].value);
            //FormsAuthentication.RedirectFromLoginPage(myfrm[0].value, false);

            FormsAuthenticationTicket tkt;
            string cookiestr;
            HttpCookie ck;
            tkt = new FormsAuthenticationTicket(1, myfrm[0].value, DateTime.Now,
            DateTime.Now.AddMinutes(30), true, "my custom data");
            cookiestr = FormsAuthentication.Encrypt(tkt);
            ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);

            ck.Path = FormsAuthentication.FormsCookiePath; 
            //  ******* now i must somthing like this: -->  Response.Cookies.Add(ck);
            // but im in static method don't have respons request objects
            // i want respons in json form and proccess the json


           // return "Success";
        }
        else
        {
            //return "Faild";
        }

    }

だからタンク

4

1 に答える 1