حرفه ای: ورود به سایت با گوگل

ساخت وبلاگ
سلام من میخوام با گوگل تو سایتم لوگ این کنم..تنها مشکلی که هست اینه که وقتی به سایت بر میگرده خطای زیر رو میده:
Cannot convert object of type 'System.String' to type '?2?.?3?.?5?'

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Cannot convert object of type 'System.String' to type '?2?.?3?.?5?'

Source Error:

Line 1175: string code = Request.QueryString["code"];
Line 1176:
Line 1177: string json = GoogleConnect.Fetch("me", code);
Line 1178: GoogleProfile profile = new JavaScriptSerializer().Deserialize( json);
Line 1179: GoogleConnect.Clear(Request.QueryString["code"].ToString());
کد مربوط به لوگ این:
[HttpGet]
[Route("LoginGoogle")]
public void LoginGoogle()
{
GoogleConnect.ClientId = "482352026499-51empr7iklqakhf4d1tjpkr0uj5lhdj4.apps.googleuserco ntent.com";
GoogleConnect.ClientSecret = "7FwT1OefVxpofym32R3fL0td";GoogleConnect.RedirectUri = "http://localhost:8089";if (!string.IsNullOrEmpty(Request.QueryString["code"]))
{
string code = Request.QueryString["code"];string json = GoogleConnect.Fetch("me", code);
GoogleProfile profile = new JavaScriptSerializer().Deserialize( json);
GoogleConnect.Clear(Request.QueryString["code"].ToString());
string name = profile.DisplayName;
string Email = profile.Emails.Find(email => email.Type == "account").Value;
SysAction.User us = new SysAction.User();
if (us.GetIsEmail(Email) == false)
{
Response.Write("");}
else if (us.GetIsEmail(Email, true) == false)
{FormsAuthentication.RedirectFromLoginPage(Email, false);
}
else
{
if (us.SaveUser(Email, "", Email, name, 0, "", true) == true)
{FormsAuthentication.RedirectFromLoginPage(Email, false);
}
else
{
Response.Write("");
}}
}
if (Request.QueryString["error"] == "access_denied")
{
Response.Write("");
}
}
private class GoogleProfile
{
public string Id { get; set; }
public string DisplayName { get; set; }
public List Emails { get; set; }
public string Gender { get; set; }
}private class Email
{
public string Value { get; set; }
public string Type { get; set; }
}
برنامه نویس...
ما را در سایت برنامه نویس دنبال می کنید

برچسب : نویسنده : محمد رضا جوادیان programers بازدید : 241 تاريخ : سه شنبه 24 بهمن 1396 ساعت: 1:36