protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["usuario"] == null)
            {
                string cadena  = "Debe iniciar sesion primero.";
                int    count   = cadena.Count();
                string mensaje = QueryStringModule.Encrypt(cadena);
                Response.Redirect("../Login.aspx" + mensaje.Replace("enc", "mensaje"), false);
                Context.ApplicationInstance.CompleteRequest();
            }
            else
            {
                if (Session["estado"] != null)
                {
                    Session["estado"] = null;
                }
                else if (Request.QueryString["mensaje"] != null)
                {
                    string mensaje = QueryStringModule.Decrypt(Request.QueryString["mensaje"]);
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + mensaje.Replace(".", "").Replace("%20", " ") + "');", true);
                }

                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                //if (!this.IsPostBack)
                //{
                Session["Reset"] = true;
                Configuration       config  = WebConfigurationManager.OpenWebConfiguration("~/Web.Config");
                SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");
                int timeout = (int)section.Timeout.TotalMinutes * 60000;
                ClientScript.RegisterStartupScript(this.GetType(), "SessionAlert", "SessionExpireAlert(" + timeout + ");", true);
                //}
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Conection obj = new Conection();

            obj.set_ConexionString(ConfigurationManager.ConnectionStrings["MyConexion"].ConnectionString);
            if (Session["usuario"] != null)
            {
                Response.Redirect("Inicio.aspx", false);
                Context.ApplicationInstance.CompleteRequest();
            }
            else
            {
                if (Request.QueryString["mensaje"] != null)
                {
                    string mensaje = QueryStringModule.Decrypt(Request.QueryString["mensaje"]);
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + mensaje.Replace(".", "").Replace("%20", " ") + "');", true);
                }
            }
        }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        myConnection = new SqlConnection(connectionString);
        // Determine the sections to render
        UserManager manager = new UserManager();

        if (UserExists(manager))
        {
            HasRegistered.Visible   = true;
            NeedsToRegister.Visible = false; // change to FALSE for deploy

            // Set up meal details
            mealChefNameLabel.Text = User.Identity.GetUserName().ToString();
            Uri    editMealURI     = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
            string encryptedString = HttpUtility.ParseQueryString(editMealURI.Query).Get("enc");
            string decryptedString = QueryStringModule.Decrypt(encryptedString);
            mealID = HttpUtility.ParseQueryString(decryptedString).Get("yum");
            if (CheckMealHost())
            {
                mealIDField.Value = mealID;
                if (!IsPostBack)
                {
                    SetMealDetails();
                }
            }
            else
            {
                mealID = "0";
                throw new Exception("Page not found.");
            }
        }
        else
        {
            HasRegistered.Visible   = false; // change to FALSE for deploy
            NeedsToRegister.Visible = true;
            mealChefNameLabel.Text  = "unregistered";
        }
    }