Você está na página 1de 3

ASP.

NET SESSION
1. keep information specific to each of your site's visitors(username, location, preferences etc.
a. session variables are stored in the web server.
CREATE SESSION variable
Session(username) = value
Session timeout default is 20 mins
Session.Timeout = value in minutes
ASP.NET APPLICATION VARIABLE
-

INFORMATION VISIBLE TO ALL MODULES OF THE SITE


Defined in the Global Application Class (global.asax)
Use Lock() and Unlock() to prevent visitors from accessing/modifiying the global variable at
the same time

Appilication(UserCounter) = 0

Application.Lock()
Appilication(UserCounter) += 1
Application.UnLock()

HOW TO ADD
1. Right click the website from solution explorer
2. Select add new item
3. From the list select Global Application Class

Global Application Class


Global application class settings are available to all users accessing a Website. For example, if there are 200 users on a Website, all 200 users
can access same application class variables/data and all of them will see same values.
A Session belongs to a single user/browser session only. So if there are 200 users accessing same application, every user will have their own
Session variables/data and that will be seperate for every body.
You want to put data in application state that is common to all users. For example, database connection string or some static data that never
changed based on a user.
Global.asax class also have many events that are common to application as well as some events are for Session etc. This is just a single place
to have all events for an application.

Application_Start:
As with traditional ASP, used to set up an application environment and only called when the
application first starts.

Application_Init:
This method occurs after _start and is used for initializing code.
Application_Disposed:
This method is invoked before destroying an instance of an application.
Application_Error:
This event is used to handle all unhandled exceptions in the application.
Application_End:
Again, like classic ASP, used to clean up variables and memory when an application ends.
Application_BeginRequest:
This event is used when a client makes a request to any page in the application. It can be useful
for redirecting or validating a page request.
Application_EndRequest:
After a request for a page has been made, this is the last event that is called.
Session_Start:
As with classic ASP, this event is triggered when any new user accesses the web site.
Session_End:
As with classic ASP, this event is triggered when a user's session times out or ends. Note this can
be 20 mins (the default session timeout value) after the user actually leaves the site.

MASTER PAGE
Master Pages enables us to apply the same page layout to multiple pages in a Web
Application. A page that uses a master page is known as the content page.(draw usual page
with master page, using a banner and a menu navigation on the left pane)

HOW TO ADD
4. Right click the website from solution explorer
5. Select add new item
6. From the list select Master Page
ADD MENU CONTROL

Under NAVIGATION TOOLBOX select MENU


Drag inot the appropriate location in the master page
Click upper right button, select edit menu items


HOW TO USE MASTER PAGE
1.
2.
3.
4.
5.

Right click the website from solution explorer


Select add new item
From the list select WEB FORM
CHECK Use Master PAge option
Click ADD, select the master page to use

<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
PUBLISH/DEPLOY WEBSITE

Rick Click website in the solution explorer, select Publish website


Select the location where to publish

Você também pode gostar