| C# | Page Context | Top |
|
/*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 Server | Top |
//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 Server.Transfer("Login.aspx",true); //setting the request time out to 30 seconds Server.ScriptTimeout=30
|
|
| C# | Page Cache | Top |
//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[]); }
|
|
| C# | Page Trace | Top |
|
/* 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 Trace.TraceMode=TraceMode.SortByTime; //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");
|
|