About us |  Help us improve
intelliVERB - Get a fair search of the Internet !
Visual studio .net
SQL Server
Main  >  Web Objects Email this page to friend
Application State
Page Cache
Page Context
Page Request
Page Response
Page Server
Page Trace
C#Application StateTop
//Application object is visible and accessible by all the clients
//Application state data is stored in the application's Global.asax file
private class ClientEnvironment
 public string Browser;
 public string Platform;
 public bool SupportJS;
 public string Version;
 public bool IsCrawler;
private ClientEnvironment oClientBrowser
  if (Application["Browser"]==null)
   ClientEnvironment oClientEnvironment=new ClientEnvironment();
   //saving the client environment object in the application object
  return (Application["Browser"] as ClientEnvironment);

C#Page ContextTop

/*Page.Context Property provides access to the context in wich the current page is running,as well as information about the request, response, session and application*/

//capturing all page errors
Exception[] aException=Context.AllErrors;

C#Page RequestTop
//getting application path
string Path=Request.ApplicationPath;
//checking if the browser supports cookies
bool SupportsCookies=Request.Browser.Cookies;
//getting browser name
string Browser=Request.Browser.Browser;
//getting client Login cookie
if (Request.Cookies["Login"]!=null)
//checking if the connection is secure
bool isHTTPS=Request.IsSecureConnection;
//checking if the client is a search engine crawler
bool isCrawler=Request.Browser.Crawler;
//request the page object UserName value
string UserName=Request["UserName"];
//get the client transfer method: GET, POST, HEAD
string Method=Request.HttpMethod; 

C#Page ResponseTop
//sending a cookie to the client
Response.Cookies.Add(new HttpCookie("Login","Empl/Dept"));
//redirecting the client to the Login.aspx URL
//setting the client status line value
Response.StatusDescription="Entering the accounting system";
//Setting the cache expiration time
//Closing client socket connection

C#Page ServerTop
//getting the server name
string ServerName=Server.MachineName;
//getting the physical path corresponding to my virtual path
string FilesPath=Server.MapPath("/SampleCodePool");
//stops execution of the current page and start Login.aspx page
//setting the request time out to 30 seconds

C#Page CacheTop
//given the class
private class Language
 public string Code;
 public string Value;
 public string TranslatedValue1;
 public string TranslatedValue2;
 public string TranslatedValue3;
private void usingCache()
 Language[] aLanguage = new Language[0];
 //populate the language object array
 /*The cache is not associated with a page or user session.
 It's use is recommended for performance enhancement
 when storing in memory objects that require a large
 amount of server resources*/
 //caching Language content list

 Cache["Language"] = aLanguage;
 //retrieving image list
 aLanguage = (Cache["Language"] as Language[]);


/*Control.Controls Property  represent a collection of
 child controls to the current server control*/

//getting number of children server control
int nControl=Controls.Count;
Controls.Add(new LiteralControl("User Name"));
TextBox txtUserName=new TextBox();
this.Controls.Add(new LiteralControl("Password"));
TextBox txtPassword=new TextBox();
Button btnSubmit=new Button();

C#Page TraceTop

The Trace object keep tracks of the execution details of a Web request.
To use Trace on a page, you must enable tracing at the page or application level.
Tracing on a page is disabled by default. Set the Page directive:
<%@ Page trace="true" %> To enable tracing on a page.
At the application level, you can enable tracing by setting parameters in the config file: <trace enabled="true" requestLimit="50" localOnly="true"/>


//always check if tracing is enabled to avoid application overhead
bool isTraceEnabled=Trace.IsEnabled;
//Sorting trace messages by processing time
//writting user trace message
Trace.Write("Proceeding with login process");
//writting a warning message into the trace log
//warnings appear in the log as red text

Trace.Warn("User already logged into the system");


 ViewSate object is and instance of the StateBag class
 A server control's view state is the container of
 all its property and object values.
 In ASP .net Control. ViewState Property is use to
 preserve these values across HTTP requests.

//getting the number of object in our viewstate
int nItems=ViewState.Count;
//Scrolling trough the list of item in the view state collection
foreach.(StateItem Item in ViewState.Values)

You last visited
Object Oriented C# .net
ADO .net
Make a secure donation now with PayPal!