コード例 #1
0
ファイル: Login.aspx.cs プロジェクト: s290305915/SucFramework
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SucCookie.Exists("username"))
     {
         SucCookie.Delete("username");
     }
 }
コード例 #2
0
        protected void btn_download_Click(object sender, EventArgs e)
        {
            if (SucCookie.Exists("username"))
            {
                try
                {
                    id       = SucCookie.Read("fileid");
                    FilePath = db.GetList(string.Format("SELECT FILEPATH FROM SUC_FILES WHERE ID={0}", id))[0];
                    Name     = db.GetList(string.Format("SELECT NAME FROM SUC_FILES WHERE ID={0}", id))[0];
                    string fileName = Name + FilePath.Substring(FilePath.LastIndexOf('.')); //客户端保存的文件名
                    string filePath = Server.MapPath(FilePath);                             //路径

                    //以字符流的形式下载文件
                    FileStream fs    = new FileStream(filePath, FileMode.Open);
                    byte[]     bytes = new byte[(int)fs.Length];
                    fs.Read(bytes, 0, bytes.Length);
                    fs.Close();
                    Response.ContentType = "application/octet-stream";
                    //通知浏览器下载文件而不是打开
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
                    Response.BinaryWrite(bytes);
                    Response.Flush();
                    Response.End();
                }
                catch (Exception ex)
                {
                    JsUtil.ShowMsg("文件保存出错,请联系网站管理员!");
                }
            }
            else
            {
                JsUtil.ShowMsg("您尚未登陆,请先登录然后才能下载!", "UserLogin.aspx");
            }
        }
コード例 #3
0
        private string GenerateCheckCode()
        {
            //利用random()随机产生四位大写的字符串(包含数字和字母)

            int    number;
            char   code;
            string checkCode = string.Empty;
            Random random    = new Random();

            for (int i = 0; i < 4; i++)
            {
                number = random.Next();

                //下面也可以用其他的方法构思
                if (number % 2 == 0)
                {
                    code = (char)('0' + (char)(number % 10));
                }
                else
                {
                    code = (char)('A' + (char)(number % 26));
                }
                checkCode += code.ToString();
            }

            //用cookies保存刚刚产生的随机字符串
            //Session["CheckCode"] = checkCode;
            if (SucCookie.Exists("CheckCode"))
            {
                SucCookie.Delete("CheckCode");
            }
            SucCookie.Add("CheckCode", checkCode, 30);
            return(checkCode);
        }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!SucCookie.Exists("username"))
     {
         JsUtil.ShowMsg("登录已过时,请重新登录!", "Login.aspx");
     }
     GetFunction();
 }
コード例 #5
0
 protected void lk_quitlogin_Click(object sender, EventArgs e)
 {
     if (SucCookie.Exists("username"))
     {
         SucCookie.Delete("username");
         lk_loginstate.Text   = "请登陆";
         lk_quitlogin.Visible = false;
         lk_modifypwd.Visible = false;
     }
 }
コード例 #6
0
 protected void lk_upload_Click(object sender, EventArgs e)
 {
     //SucCookie.Add("username", "suchi", 30);
     //SucCookie.Delete("username");
     if (SucCookie.Exists("username"))
     {
         Response.Redirect("FileUpload.aspx");
         return;
     }
     Response.Redirect("UserLogin.aspx");
 }
コード例 #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (SucCookie.Exists("username"))
     {
         username = SucCookie.Read("username");
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
コード例 #8
0
 protected void lk_upload_Click(object sender, EventArgs e)
 {
     //SucCookie.Add("username", "suchi", 30);
     //SucCookie.Delete("username");
     if (SucCookie.Exists("username"))
     {
         //Response.Write("<script>javascript:window.open  ('FileUpload.aspx','文件上传', 'height=700, width=1200')</script>");
         //Response.Write("<script language='javascirpt'>window.showModalDialog('FileUpload.aspx?', window, 'dialogWidth:800px;dialogHeight:440px;center:yes;status:no;scroll:yes;help:no');</script>");
         Response.Redirect("FileUpload.aspx");
         return;
     }
     Response.Redirect("UserLogin.aspx");
 }
コード例 #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string UserN = SucCookie.Read("username");
         if (!string.IsNullOrEmpty(UserN))
         {
             lk_loginstate.Text   = UserN;
             lk_quitlogin.Visible = true;
             lk_modifypwd.Visible = false;
         }
         id = Request.QueryString["id"];
         if (SucCookie.Exists("fileid"))
         {
             SucCookie.Delete("fileid");
         }
         SucCookie.Add("fileid", id, 10);
         GetInfo(id);
         LoadMedia();
         LoadInfo(id);
         AddBrowNum(id);
     }
 }