开发者

My one value is reflecting on another application in MVC?

开发者 https://www.devze.com 2023-03-08 04:44 出处:网络
When I open two applications in different browsers or in the same browser, the value which I added in one application is visible to the other application.

When I open two applications in different browsers or in the same browser, the value which I added in one application is visible to the other application.

I have made a session helper but i am still in problem.

public class SessionHelper
{
    #region Strongly typed variable
    public static CreateAccountModel tmpmodel = null;
    public static string errMsg = string.Empty;
    public static List<PointOfSalesModel> CurrPosModelArr = null;
    public static List<PointOfSaleUsersModel> currAddedClerks = null;
    public static List<AuthorizedIPsModel> currAddedIPs = null;
    public static bool isPosDataLodedFirstTime = false;
    public static string isEditGridClickedVal = "No";
    public static int AccountId = -1;
    #endregion

    public SessionHelper Current
    {
        get
        {
            SessionHelper currentSession = HttpContext.Current.Session["_session"] as SessionHelper;
            if (currentSession == null)
            {
                currentSession = new SessionHelper();
                HttpContext.Current.Session["_session"] = currentSe开发者_如何学Cssion;
            }
            return currentSession;
        }
    }
}


Static fields/properties are shared across all your requests made from browsers. So even though you save it to the session, but each SessionHelper will have same static fields referenced. Use instance fields instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消