0

ChromeとMozillaで正常に動作しているasp.netページがありますが、SafariまたはIE9にロードすると、ページが2回表示されます。2回目にページを起動すると、セッションはnullになります。SafariとIE9がページを2回起動する理由がわかりません。

私のコードは次のとおりです:-

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";
            }
        }
    }

誰かが解決策を持っていますか?

ご協力いただきありがとうございます

4

2 に答える 2

0

RecentVoteDriverこのデフォルト値を設定し て編集してみてくださいImage1.ImageUrl(場合によっては、if-else 句の画像がどれも設定されていないことがありますか?)。

理由

ページにレンダリングされた html を見てください。

存在するたびに

<img src=""/>

一部のブラウザでは、二重のポストバックが発生する可能性があります...

これが問題である場合は、すべてのボタンにデフォルトの空白の画像を設定して解決できます

<asp:ImageButton ImageUrl="~/Images/blank.gif"...
于 2012-07-06T15:54:24.437 に答える
0
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";
            }
        }
    }
于 2012-07-06T15:52:02.190 に答える