Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Built in Objects in ASP.NET

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 5.45k
    Comment on it

    ASP stands for Active Server Pages. By using ASP built-in objects, we can get the information related to the web server, web pages in the web application etc. the built-in objects are categorized according to the information it contain.

    Following are the built-in objects in cakePHP

    •  Application
    • Request
    • Response
    • Server
    • Session

    1. Application-

    Application object is used to share information between all users of application. In application more then one user can use that method at a time, so there is lock and unlock method so that multiple users can not use a property at same time.

    Methods in Application object:-

    • Application.Contents.Remove- Used to delete an item from the application.
    • Application.Contents.RemoveAll- Used to delete all items from the application.
    • Application.Lock- Used so that unauthorized users can not make changes.
    • Application.Unlock- Allows unauthorized users to make changes.

    E.g of Application object:-

    1. <%
    2. Application.Lock
    3. Application("NumVisits") = Application("NumVisits") + 1
    4. Application.Unlock
    5. %>
    6.  
    7. This application page has been visited
    8. <%= Application("NumVisits") %> times!
    9.  

     

    2. Request Objects-

    Used to get the data that was sent by the client browser to the server.

    Method in Request objects:-

    • Request.BinaryRead- Used to retrieve the data.
    • Request.Form- Reads data sent by POST.
    • Request.QueryString- Reads data sent by GET.

    E.g of Request object:-

     

    1. <%
    2. Response.Write "Welcome " & Server.HTMLEncode(Request.QueryString("name")) & "!"
    3. %>

     

    3. Response Object-

    Used to send information to the client.

    Methods in Response objects:-

    • Response.AddHeader- Used to set header
    • Response.AppendToLog- Used to add data at the end of the web page.
    • Response.BinaryWrite- Used to set information in the current HTTP output.
    • Response.Clear- Used to erase the output.
    • Response.End- Used to end the processing.

     

    E.g of Response object:-

    1. <%
    2. If Len(Request.QueryString("name")) > 0 Then
    3. Response.Cookies("name") = Request.QueryString("name")
    4. End If
    5.  
    6. Response.Write "Welcome " & Server.HTMLEncode(Response.Cookies("name")) & "!"
    7. %>

     

    4. Server Object-

    Methods and properties on the server are accessed by Server object. It also allows connection to the database.

    Methods in Server object:-

    • Server.CreateObject- Used to create an instance of server component.
    • Server.Execute- Used to execute .asp file.
    • Server.HtmlEncode- Encode html code into specific string.
    • Server.Transfer- Sends all current information to another .asp file for processing.
    • Server.URLEncode- Apply URL encoding rules.

     

    E.g of Server object:-

    1. <%
    2. Dim oAdoCon, oAdoRec, oAdoStm, oCdoCon, oCdoMsg, oSciDic, oSciFsm, oMswAdr
    3.  
    4. Set oAdoCon = Server.CreateObject("ADODB.Connection")
    5. Set oAdoRec = Server.CreateObject("ADODB.Recordset")
    6. Set oAdoStm = Server.CreateObject("ADODB.Stream")
    7. Set oCdoCon = Server.CreateObject("CDO.Configuration")
    8. Set oCdoMsg = Server.CreateObject("CDO.Message")
    9. Set oSciDic = Server.CreateObject("Scripting.Dictionary")
    10. Set oSciFsm = Server.CreateObject("Scripting.FileSystemObject")
    11. Set oMswAdr = Server.CreateObject("MSWC.AdRotator")
    12. %>

     

    5. Session Object-

    Used to store information only needed for a particular visitor.

    Methods in Session object:-

    • Session.Abandon- Destroys session object and release it's resources.
    • Session.Contents.Remove- Deletes an item.
    • Session.Contents.RemoveAll- deletes all items.

    E.g of Session object:-

    1. <%
    2. If Len(Request.QueryString("name")) > 0 Then
    3. Session("name") = Request.QueryString("name")
    4. End If
    5.  
    6. Response.Write "Welcome " & Server.HTMLEncode(Session("name")) & "!"
    7. %>

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: