仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2334|回复: 18
打印 上一主题 下一主题

[学习教程] ASP网页设计Applications, Sessions, and Global.a...

[复制链接]
灵魂腐蚀 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-3 23:39:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。application|session   One of the things that most new ASP users find confusing is the concept of Sessions and Applications. Add to this the fact that there's this special file on the web server called global.asa that is somehow related (and yet can't be requested via a browser) and it makes for a very confusing situation indeed. That's why I'm writing this article. This isn't going to be a comprehensive discussion of everything you can do using Sessions, Applications, and the Global.asa, but is instead meant as an introductory level overview to try and alleviate some of the confusion and misconceptions associated with these topics.

Sessions

Of the topics I'm covering, people usually have the easiest time with the concept of a session so I'll cover it first. This probably stems from the fact that almost all computing used to be done this way. You'd log on, do what you needed to do and then log off. In fact most programs still work that way. For example when you start Windows the first thing you is log in. Then you do what you have to do and when your done you log off. Similarly, when you need to do something in an application, you open the application, do what you want to do and then close it. This scenario is similar to a session, but when it comes to the web there is one problem... the protocol of the web (HTTP) doesn't maintain state. This is like using a word proccessor that with every word you type forgets what document it belongs in or even that it's you typing it!

So if no state is maintained then the web server doesn't know who you are, if you're still reading the content it gave you, or even if you're already long gone. It really doesn't care and if you think about it, the concept really does make sense for static pages. If you're just publishing a document for everyone to see, what difference does it make who you are or what you've already done if you're going to get the same page as everyone else anyway? So the question then becomes, why should the server waste the resources needed to track users and maintain their information between requests? Well as you'd expect (or at least infer from my rambling on about it) the web server doesn't!

Now along comes ASP and suddenly we're not serving static pages anymore. Some people get one thing and others get something entirely different. And not just that... we want to let a user do things that might take more that one request. So what are we supposed to do... make the user tell us who they are and everything about themselves with every request? Well that would certainly make our lives easier, but I don't think visitors to your web site would like it very much!

So, as always seems to happen when we have a problem like this, ASP comes to our rescue and maintains state for us. It does this by creating a unique cookie and sending it to the client. This cookie then acts as an identifier so that the server knows which set of session information on the server is associated with which requests. So it's important to note that while all information in a session is actually stored on the server and not transmitted to the browser, the fact remains that cookies need to be enabled in order for the server to track a users session. Using this combination of server side storage and cookies, ASP provides us with a nice neat way to use this information without having to worry about how it's actually done. This interface is called the Session object.

While the Session object does have some useful properties and methods, the most important thing about it is that you can place variables in it and it will maintain them for you until the session ends. For example:

Session("FirstName") = "John"
will set the Session variable FirstName to John (which if you couldn't guess is my first name). Now that I've stored the value in a session variable I can access it on any subsequent page by simply using:

Session("FirstName")
Except for the fact that it doesn't go away when the page is done executing, it behaves the same as any other variable in ASP and can be used in the same manner.

Those of you who were paying attention probably caught that I mentioned that these variable are only good until the session ends and yet I didn't tell you when that happens. This is the main problem with sessions and why they've gotten such a bad reputation. You see, since we don't know if a users going to come back or not (because of the stateless nature of HTTP) we don't know how long to keep their session alive. Until the next request, we never know if the last one was their final one or if they're going to be right back. This leaves us with somewhat of a dilemma. If we wait too long then we're storing all the users information and using up resources on the server that could almost certainly be better used for something el</p>  Windows本身的所有问题都会一成不变的也累加到了它的身上。安全性、稳定性、跨平台性都会因为与NT的捆绑而显现出来;
兰色精灵 该用户已被删除
沙发
发表于 2015-2-4 04:50:11 | 只看该作者
接下来就不能纸上谈兵了,最好的方法其实是实践。实践,只能算是让你掌握语言特性用的。而提倡做实际的Project也不是太好,因为你还没有熟练的能力去综合各种技术,这样只能使你自己越来越迷糊。
愤怒的大鸟 该用户已被删除
板凳
发表于 2015-2-6 09:38:49 | 只看该作者
在平时的学习过程中要注意现学现用,注重运用,在掌握了一定的基础知识后,我们可以尝试做一些网页,也许在开始的时候我们可能会遇到很多问题,比如说如何很好的构建基本框架。
再现理想 该用户已被删除
地板
发表于 2015-2-15 22:08:12 | 只看该作者
我想问如何掌握学习节奏(先学什么再学什么)最好详细点?
灵魂腐蚀 该用户已被删除
5#
 楼主| 发表于 2015-3-10 10:18:47 | 只看该作者
兴趣爱好,那么你无须学编程,申请一个域名和空间,在网上下载一些免费开源的CMS系统,你不用改代码,只须熟悉它们的后台操作,像office一样简单方便,很快就能建一个站点,很多站长都是这样做的
精灵巫婆 该用户已被删除
6#
发表于 2015-3-17 06:10:14 | 只看该作者
学习是为了用的,是为了让你的程序产生价值,把握住这个原则会比较轻松点。除此之外,课外时间一定要多参加一些社会实践活动,来锻炼自己的能力。
金色的骷髅 该用户已被删除
7#
发表于 2015-3-23 22:42:27 | 只看该作者
你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。
简单生活 该用户已被删除
8#
发表于 2015-4-6 13:04:39 | 只看该作者
代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
admin 该用户已被删除
9#
发表于 2015-4-9 03:52:46 | 只看该作者
那么,ASP.Net有哪些改进呢?
活着的死人 该用户已被删除
10#
发表于 2015-4-12 13:55:47 | 只看该作者
下面简单介绍一下我学习ASP的方法,希望对想学习ASP的朋友有所帮助...
海妖 该用户已被删除
11#
发表于 2015-5-1 03:43:06 | 只看该作者
我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。
莫相离 该用户已被删除
12#
发表于 2015-5-3 11:38:43 | 只看该作者
以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。
不帅 该用户已被删除
13#
发表于 2015-6-9 23:24:22 | 只看该作者
它可通过内置的组件实现更强大的功能,如使用A-DO可以轻松地访问数据库。
因胸联盟 该用户已被删除
14#
发表于 2015-6-20 04:05:19 | 只看该作者
运用经典的例子。并且自己可以用他来实现一些简单的系统。如果可以对他进行进一步的修改,找出你觉得可以提高性能的地方,加上自己的设计,那就更上一个层次了,也就会真正地感到有所收获。
飘飘悠悠 该用户已被删除
15#
发表于 2015-6-26 18:33:53 | 只看该作者
Response:从字面上讲是“响应”,因此这个是服务端向客户端发送东西的,例如Response.Write
柔情似水 该用户已被删除
16#
发表于 2015-7-9 05:29:16 | 只看该作者
Server:这个表示的服务器,操作服务器的一些东西使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件
第二个灵魂 该用户已被删除
17#
发表于 2015-7-15 01:57:10 | 只看该作者
以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。
小妖女 该用户已被删除
18#
发表于 2015-7-18 09:07:48 | 只看该作者
我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标.
只想知道 该用户已被删除
19#
发表于 2015-7-22 21:43:16 | 只看该作者
另外因为asp需要使用组件,所以了解一点组件的知识(ADODB也是组件)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-22 18:58

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表