Server side Programming Assignment Help

Assignment Help: >> ASP.Net Programming >> Server side Programming

Server side Programming:

We have described the page life cycle and how a page has several controls. The page itself is instantiated as a control button. All web forms are usually instances of the ASP.Net Page class. The page class obtains the following extremely needful properties that related to intrinsic objects like:

  • Session.
  • Application
  • Cache
  • Request
  • Response
  • Server
  • User
  • Trace

We will shown each of these objects in related time. In this part we will defines the Server object, the Request object and the Response object.

The Server Object:

The Server object in Asp.Net is a part of the System.Web.HttpServerUtility class. The HttpServerUtility class gives numerous properties and functions to perform several jobs.

Properties and Methods of the Server object:

The function and properties of the HttpServerUtility class are explained through the intrinsic Server object given by ASP.NET.

The given table gives a list of the properties:

Property

Description

MachineName

Name of server's computer

ScriptTimeOut

Gets and sets the request time-out value in seconds.

The following table gives a list of some very important methods:

Method

Description

CreateObject(String)

Creates an instance of the COM object identified by its ProgID (Programmatic ID)

CreateObject(Type)

Creates an instance of the COM object identified by its Type

Equals(Object)

Determines whether the specified Object is equal to the current Object

Execute(String)

Executes the handler for the specified virtual path in the context of the current request.

Execute(String, Boolean)

Executes the handler for the specified virtual path in the context of the current request and specifies whether to clear the QueryString and Form collections

GetLastError

Returns the previous exception.

GetType

Gets the Type of the current instance.

HtmlEncode

Changes an ordinary string into a string with legal HTML characters.

HtmlDecode

Converts an Html string into an ordinary string

ToString

Returns a String that represents the current Object

Transfer(String)

For the current request, terminates execution of the current page and starts execution of a new page by using the specified URL path of the page.

UrlDecode

Converts an URL string into an ordinary string

UrlEncodeToken

Works same as UrlEncode, but on a byte array that contains Base64-encoded data

UrlDecodeToken

Works same as UrlDecode, but on a byte array that contains Base64-encoded data

MapPath

Return the physical path that corresponds to a specified virtual file path on the server

Transfer

Transfers execution to another web page in the current application

The Request Object:

The request object is a part of the System.Web.HttpRequest class. It shows the properties and values of the HTTP request that creates the page loading into the browser.

The information shown by this object is wrapped up by the higher level abstractions (the web control model), however, this object provides in checking some data like the cookies and client browser.

Properties and Methods of the Request Object:

The given table provides some noteworthy parts of the Request object:

Property

Description

AcceptTypes

Gets a string array of client-supported MIME takes types.

ApplicationPath

Gets the ASP.NET application's virtual application root way on the server.

Browser

Sets or gets information about the requesting client's browser capabilities.

ContentEncoding

Sets or gets the character set of the page.

ContentLength

Indicates the length, in bytes, of content sent by the client.

ContentType

Sets or gets the MIME content part of the incoming request.

Cookies

Sets a part of cookies provided by the client.

FilePath

Sets the virtual path of the present request.

Files

Sets the collection of files related by the client, in multipart MIME format.

Form

Gets a portion of form variables.

Headers

Gets a collection of HTTP headers.

HttpMethod

Gets the HTTP data transmit function (such as GET, POST, or HEAD) used by the client.

InputStream

Gets the code of the incoming HTTP entity body.

IsSecureConnection

Gets a value showing whether the HTTP connection uses secure sockets (that is, HTTPS).

QueryString

Gets the part of HTTP query string variables.

RawUrl

Gets the URL of the present request.

RequestType

Sets or gets the HTTP data transfer function (GET or POST) used by the client.

ServerVariables

Gets a part of Web server variables.

TotalBytes

Gets the number of bytes in the present input stream.

Url

Gets information about the URL of the present request.

UrlReferrer

Gets data about the URL of the client's previous request that related to the current URL.

UserAgent

Gets the raw user agent string of the client browser.

UserHostAddress

Gets the IP host address of the remote client.

UserHostName

Gets the DNS name of the remote computer.

UserLanguages

Gets a sorted string array of client language existence.

The given table gives a list of some very important methods:

Method

Description

BinaryRead

Operates a binary defines of a specified value of bytes from the present input stream.

Equals(Object)

Calculates whether the specified Object is same to the current Object. (Inherited from Object.)

GetType

Gets the kind of the current instance.

MapImageCoordinates

Maps an incoming image-field form parameter to related x-coordinate and y-coordinate values.

MapPath(String)

Maps the given virtual path to a physical path.

SaveAs

Saves an HTTP request to disk.

ToString

Returns a String that represents the current Object

ValidateInput

Causes validation to happen for the collections accessed through the Cookies, QueryString properties and Form.

The Response Object:

The Response object shows the server's response to the client request. It is a parts of the System.Web.HttpResponse class.

In ASP.Net, the Response object does not go a vital part in receiving HTML text to the client, related the server-side controls have object oriented, nested functions for rendering themselves.

However, the HttpResponse object still gives some very important functionalities, like the cookie function and the Redirect() function. The Response.Redirect() function gives related the user to other page, inside as well as outside the application. It needs a round trip.

Properties and Methods of the Response Object:

The following table gives some noteworthy properties of the Response object:

Property

Description

Buffer

Gets or sets a value showing whether to buffer part and send it after the given response is finished processing.

BufferOutput

Gets or sets a value showing whether to buffer output and transmit it after the complete page is completed processing.

Charset

Sets or gets the HTTP character set of the output stream.

ContentEncoding

Sets or gets the HTTP character set of the output stream.

ContentType

Sets or gets the HTTP MIME type of the output stream.

Cookies

Sets the response cookie collection.

Expires

Sets or gets the number of minutes before a page cached on a browser expires.

ExpiresAbsolute

Sets or gets the absolute date and time at which to remove cached information from the cache

HeaderEncoding

Sets or gets an Encoding object that represents the encoding for the current header output stream.

Headers

Gets the collection of response headers.

IsClientConnected

Sets a value showing whether the client is still connected to the server.

Output

Activates output of text to the outgoing HTTP response stream.

OutputStream

Activates binary output to the outgoing HTTP content body.

RedirectLocation

Sets or gets the value of the Http Location header.

Status

Sets the Status line that is returned to the client.

StatusCode

Sets or gets the HTTP status code of the output returned to the client.

StatusDescription

Sets or gets the HTTP status string of the output returned to the client.

SubStatusCode

Gets or sets a value qualifying the status code of the response.

SuppressContent

Gets or sets a value indicating whether to send HTTP content to the client.

The following table provides a list of some important methods:

Method

Description

AddHeader

Includes an HTTP header to the output stream. AddHeader is provided for compatibility with smaller versions of ASP.

AppendCookie

Infrastructure. includes an HTTP cookie to the intrinsic cookie collection.

AppendHeader

Includes an HTTP header to the output stream.

AppendToLog

Includes custom log information to the Internet Information Services (IIS) log file.

BinaryWrite

Defines a string of binary characters to the HTTP output stream.

ClearContent

Clears all content output from the buffer stream.

Close

End the socket connection to a client.

End

Sends all currently buffered output to the client, stop running of the page, and raises the EndRequest event.

Equals(Object)

Calculates whether the specified Object is same to the current Object

Flush

Sends all currently buffered output to the client.

GetType

Gets the kind of the current instance.

Pics

Adds a HTTP PICS-Label header to the output stream.

Redirect(String)

Redirects a request to a new URL and indicates the new URL.

Redirect(String, Boolean)

Redirects a client to a new URL. Indicates the new URL and whether execution of the current page should terminate.

SetCookie

Updates an existing cookie in the cookie collection.

ToString

Gives a String that represents the current Object.

TransmitFile(String)

Writes the related file directly to an HTTP response output stream, without buffering it in memory.

Write(Char)

Writes a character to an HTTP response output stream.

Write(Object)

Writes an Object to an HTTP response stream.

Write(String)

Writes a string to an HTTP response output stream.

WriteFile(String)

Writes the parts of the related file directly to an HTTP response output stream as a file block.

WriteFile(String, Boolean)

Writes the text of the related file directly to an HTTP response output stream as a memory block.

Example:

The following simple example has a text box control where the user may enter name, a button to transmit the information to the server and a label control to display the URL of the client computer.

The content file:

<%@ Page Language="C#" AutoEventWireup="true"

                       CodeBehind="Default.aspx.cs"

                       Inherits="server_side._Default" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

     "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="https://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    Enter your name:<br />

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

        <asp:Button ID="Button1" runat="server"

                    OnClick="Button1_Click" Text="Submit" />

        <br />

        <asp:Label ID="Label1" runat="server"/>

 

    </div>

    </form>

</body>

</html>

The code for Button1_Click:

protected void Button1_Click(object sender, EventArgs e)

{

   if (!String.IsNullOrEmpty(TextBox1.Text))

   {

       // Access the HttpServerUtility methods through

       // the intrinsic Server object.

       Label1.Text = "Welcome, " +

       Server.HtmlEncode(TextBox1.Text) +

       ".<br/> The url is " +

       Server.UrlEncode(Request.Url.ToString());

    }

 

 }

Run the page to see the given result

 

1084_server side programming.png

 

Email based ASP.Net assignment help - homework help at Expertsmind

Are you searching ASP.Net expert for help with Server side Programming questions?  Server side Programming topic is not easier to learn without external help?  We at www.expertsmind.com offer finest service of ASP.Net assignment help and ASP.Net homework help. Live tutors are available for 24x7 hours helping students in their Server side Programming related problems. Computer science programming assignments help making life easy for students. We provide step by step Server side Programming question's answers with 100% plagiarism free content. We prepare quality content and notes for Server side Programming topic under ASP.Net theory and study material. These are avail for subscribed users and they can get advantages anytime.

Why Expertsmind for assignment help

  1. Higher degree holder and experienced experts network
  2. Punctuality and responsibility of work
  3. Quality solution with 100% plagiarism free answers
  4. Time on Delivery
  5. Privacy of information and details
  6. Excellence in solving ASP.Net queries in excels and word format.
  7. Best tutoring assistance 24x7 hours

 

 

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd