我有一个在 chrome 和 mozilla 中运行良好的 asp.net 页面,但是当我在 safari 或 IE9 中加载它时,页面会触发两次。并且当它第二次触发页面时,会话变为空。我不明白为什么 safari & IE9 会触发页面两次。
我的代码如下: -
public partial class home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FBInstance fb;
if (!IsPostBack)
{
Drivertab(Convert.ToInt32(GlobalVars.DriverType.PAVEMENT));
Drivertab(Convert.ToInt32(GlobalVars.DriverType.OFFROAD));
if (Request.Form["signed_request"] != null)
{
string payload = Request.Params["signed_request"].Split('.')[1];
var encoding = new UTF8Encoding();
var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
var json = encoding.GetString(base64JsonArray);
//Response.Write(json.ToString());
var o = JObject.Parse(json);
var lPid = Convert.ToString(o.SelectToken("page.id")).Replace("\"", "");
var isLiked = Convert.ToString(o.SelectToken("page.liked")).Replace("\"", "");
var lUserId = Convert.ToString(o.SelectToken("user_id")).Replace("\"", "");
{
string message = string.Empty;
DataTable FBUserData = StoredProcedures.ReadFacebookUserID(lUserId, out message);
hfIsUserAuthenticated.Value = "false";
if (FBUserData != null)
{
if (FBUserData.Rows.Count > 0)
{
hfIsUserAuthenticated.Value = "true";
fb = new FBInstance();
fb.BUserID = Convert.ToInt32(FBUserData.Rows[0]["UserID"]);
fb.FBUserID = FBUserData.Rows[0]["FacebookUserID"].ToString();
fb.AuthToken = FBUserData.Rows[0]["AuthToken"].ToString();
fb.IsAuthenticated = Convert.ToBoolean(FBUserData.Rows[0]["IsActive"]);
fb.NoOfVote = 0;
Session[GlobalVars.FBSession] = fb;
hfFBUserID.Value = fb.FBUserID;
RecentVoteDriver(Convert.ToInt32(GlobalVars.DriverType.PAVEMENT), fb);
RecentVoteDriver(Convert.ToInt32(GlobalVars.DriverType.OFFROAD), fb);
}
}
}
}
}
}
protected void Drivertab(int driverTypeID)
{
DataTable dt = StoredProcedures.ReadDriverCard(driverTypeID);
if (driverTypeID == 1)
{
dtDriverCard.DataSource = dt;
dtDriverCard.DataBind();
}
else
{
dtDriverCard2.DataSource = dt;
dtDriverCard2.DataBind();
}
}
public void RecentVoteDriver(int DriverTypeID, FBInstance fb)
{
DataTable dt = StoredProcedures.ReadRecentVote(fb.BUserID, DriverTypeID);
if (DriverTypeID == 2)
{
if (dt.Rows.Count > 0)
{
DateTime VoteDate = Convert.ToDateTime(dt.Rows[0]["VoteDateTime"]);
if (VoteDate.Date != DateTime.Now.Date)
{
Image1.ImageUrl = GlobalVars.ImageURL + "/DefaultDriver.jpg";
}
else
{
DataTable Rdt = StoredProcedures.ReadRecentDriverCard(Convert.ToInt32(dt.Rows[0]["DriverCardID"]));
if (Rdt.Rows.Count > 0)
{
Image1.ImageUrl = GlobalVars.ImageURL + "/drivers/" + Rdt.Rows[0]["ImageURL"].ToString();
}
else
{
Image1.ImageUrl = GlobalVars.ImageURL + "/DefaultDriver.jpg";
}
}
}
else
{
Image1.ImageUrl = GlobalVars.ImageURL + "/DefaultDriver.jpg";
}
}
else
{
if (dt.Rows.Count > 0)
{
DateTime VoteDate = Convert.ToDateTime(dt.Rows[0]["VoteDateTime"]);
if (VoteDate.Date != DateTime.Now.Date)
{
Image2.ImageUrl = GlobalVars.ImageURL + "/DefaultDriver1.jpg";
}
else
{
DataTable Rdt = StoredProcedures.ReadRecentDriverCard(Convert.ToInt32(dt.Rows[0]["DriverCardID"]));
if (Rdt.Rows.Count > 0)
{
Image2.ImageUrl = GlobalVars.ImageURL + "/drivers/" + Rdt.Rows[0]["ImageURL"].ToString();
}
else
{
Image2.ImageUrl = GlobalVars.ImageURL + "/DefaultDriver1.jpg";
}
}
}
else
{
Image2.ImageUrl = GlobalVars.ImageURL + "/DefaultDriver1.jpg";
}
}
}
有没有人有什么解决办法。
感谢您的帮助