1 / 22
文档名称:

精品PPT课件.ppt

格式:ppt   页数:22页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

精品PPT课件.ppt

上传人:wz_198622 2015/9/23 文件大小:0 KB

下载得到文件列表

精品PPT课件.ppt

相关文档

文档介绍

文档介绍:WEB应用程序设计 ()
安徽机电职业技术学院信息工程系
汪学文
@
2013年4月
课程网站:http://whitewin.
第4课内置对象
本章介绍常用的几个内部对象。
Response
Request
Application
Server
Session
Cookie
2
Session对象
使用 Session 对象存储特定的用户会话所需的信息。当用户在应用程序的页之间跳转时,存储在Session对象中的变量不会清除;

属性
SessionID、TimeOut
方法
Abandon
事件
Session_OnStart
Session_OnEnd
3
SessionID
系统会为每一个不同的用户分配不同的SessionID。当你转移到其它网页时,此SessionID不会发生变化。


Other/
4
利用Session存储信息
注:Session中存储的数据类型是对象
protected void Page_Load(object sender, EventArgs e)
{
("你现在的SessionID是:"
+ + "<br/>");
Session["Guy"] = "Jack Cafferty";
}

5
利用Session存储信息
注:Session中存储的数据类型是对象
protected void Page_Load(object sender, EventArgs e)
{
("你现在的SessionID是:"
+ +"<br/>");
string guy = Session["Guy"] as string;
("这可恶的家伙是:"+guy);
}
Other/
6
Session中存储的信息是对象(Object)
public class Book
{
public string ISBN; // 图书ISBN号
public string BookName; // 书名
public decimal Price; // 单价
public int Count; // 购书数量
}
protected void Button1_Click(object sender, EventArgs e)
{
Book book = new Book();
= "978-7-121-04968-2";
= "Visual C# .NET Web应用程序设计";
= ;
= 2;
Session["BookCart"] = book;
("~/Other/");
}
App_Code/

7
Session中存储的信息是对象(Object)
protected void Page_Load(object sender, EventArgs e)
{ Book book = Session["BookCart"] as Book;
if (book != null)
{ ("你购买的书的信息如下:<br/>");
("ISBN:" + + "<br/>");
("书名:" + + "<br/>");
("单价:" + + "<br/>");
("数量:" + + "<br/>");
}
}
Other/
8
使用Session验证用户登录
我们希望,只有登录成功的用户才能使用这个图片上传页面。否则,将会转向到登录界面。


9
使用Session验证用户登录
登录成功时,保存Session
protect