Tutorials » AspNet tutorials »

ASP.NET Objects


This article explains various objects used in ASP.NET programming.


We mentioned in come of the previous chapters that ASP.NET uses object oriented languages like C# or VB.NET. You can use any classes available in the .NET library to write robust programs.

ASP.NET provides some Classes which make web development easier. Some of the classes used specifically for ASP.NET development are:


  • System.Web.HttpRequest

  • System.Web.HttpResponse

  • System.Web.SessionState.HttpSessionState

  • System.Web.ApplicationState




Take the first example - System.Web.HttpRequest.

In the above example, HttpRequest is the name of the class, which is defined in the namespace System.Web

In object oriented programming, if you want to create an object of a class, you may use a syntax like below:


dim mySocket as Socket = new Socket()


In the above example, we are creating an object ('mySocket') for the class 'Socket'. Similary, if you need to create an object of class 'System.Web.HttpRequest', it must be something like this:


dim request as System.Web.HttpRequest = new System.Web.HttpRequest()


But the ASP.NET system has made your life easier. An object called 'Request' is already created for you, which is ready to use. You do not need to create an object for the class System.Web.HttpRequest. The name of the object is 'Request'.

Similary, there are objects created by default for the other classes like HttpResponse, System.Web.SessionState.HttpSessionState and System.Web.ApplicationState. The name of objects are 'Response', 'Session' and 'Application' respectively.

In one of the previous chapters, you learned how to display the current time using the Response.Write() method. 'Response' is the name of the object for the class 'HttpResponse' which is created by the system for you. That is why we could use 'Response.Write()' without creating an instance of the class 'HttpResponse'.

The above mentioned 4 objects are widely used in ASP.NET programming. It is important to learn these objects and their methods. You will learn more about these objects in the coming chapters.



Next Chapter: ASP.NET Request Object
Previous Chapter: TextBox and Button controls in ASP.NET
More Chapters: ASP.NET Tutorials
More Tutorials: Tutorial Index



Top Contributors
Today
    Last 7 Daysmore...

    Awards & Gifts
     
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India