Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building Applications using ASP.NET and C# / Session 15 / 1 of 17 Sessio n 15.

Similar presentations


Presentation on theme: "Building Applications using ASP.NET and C# / Session 15 / 1 of 17 Sessio n 15."— Presentation transcript:

1 Building Applications using ASP.NET and C# / Session 15 / 1 of 17 Sessio n 15

2 Building Applications using ASP.NET and C# / Session 15 / 2 of 17 Session Objectives Debug ASP.net application Output Caching Trace ASP.net application Data Caching Explain Deploy Caching into applications

3 Building Applications using ASP.NET and C# / Session 15 / 3 of 17 TracingTracing

4 Building Applications using ASP.NET and C# / Session 15 / 4 of 17 Page Level Tracing Testing Trace... Request Information

5 Building Applications using ASP.NET and C# / Session 15 / 5 of 17 Trace Information Categories Category Description Request DetailsLists all the information of the request Trace InformationLists information from standard and custom trace statements Control TreeLists all of the items in the page Cookies CollectionLists all of the cookies of the page with their values Header CollectionLists all the items of the HTTP header Form CollectionLists all of the form elements and their values being POSTed. Server Variables Lists all the server variables and their values

6 Building Applications using ASP.NET and C# / Session 15 / 6 of 17 Trace Example void Page_Init() { Trace.Warn("This is a message from the Page Init Event"); } void Page_Load(Object Sender, EventArgs E) { Trace.Write("This is a message from the Page Load Event"); } Testing Trace...

7 Building Applications using ASP.NET and C# / Session 15 / 7 of 17 Trace Example - Output

8 Building Applications using ASP.NET and C# / Session 15 / 8 of 17 Checking Trace … if(Trace.IsEnabled) { Trace.Warn(“I’m inside Init now!”); } … To check if trace is enabled

9 Building Applications using ASP.NET and C# / Session 15 / 9 of 17 Application Level Tracing

10 Building Applications using ASP.NET and C# / Session 15 / 10 of 17 Trace Tag Parameters ParameterDescription requestLimitSets the number of trace requests to store on the server. Default 10 traceModeSets wether the statistics should be arranged according to time or category (takes in value sortByCategory or sortByTime). Default sortByTime pageOutputSet whether the trace information is to be displayed at the bottom of every page. Default False EnabledSets whether application level tracing is to be enabled or disabled. Default True localOnlySets whether Tracing is enabled for localhost users or for all users. Default True

11 Building Applications using ASP.NET and C# / Session 15 / 11 of 17 Debugging an Application - 1

12 Building Applications using ASP.NET and C# / Session 15 / 12 of 17 Debugging an Application - 2

13 Building Applications using ASP.NET and C# / Session 15 / 13 of 17 CachingCaching Caching - is a technique used to increase performance by keeping frequently accessed data in memory

14 Building Applications using ASP.NET and C# / Session 15 / 14 of 17 Output Caching void Page_Load(Object Src, EventArgs E) { TimeGen.Text = DateTime.Now.ToString("G"); } Using the Output Cache this page was generated on: Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); Response.Cache.SetSlidingExpiration(true); Setting duration of cache using the following methods

15 Building Applications using ASP.NET and C# / Session 15 / 15 of 17 Data Caching - 1 void Page_Load(Object Src, EventArgs E){ DataView Source; Source = (DataView)Cache["MyCache"]; if (Source == null) { SqlConnection myConnection = new SqlConnection ("server=(local)\\NetSDK;database=pubs;uid=sa; pwd="); SqlDataAdapter myCommand = new SqlDataAdapter("select * from employee", myConnection); A

16 Building Applications using ASP.NET and C# / Session 15 / 16 of 17 Data Caching - 2 DataSet ds = new DataSet(); myCommand.Fill(ds, "employee"); Source = new DataView(ds.Tables["employee"]); Cache["MyCache"] = Source; CacheMsg.Text = "Dataset created from Table"; } else { CacheMsg.Text = "Dataset retrieved from Cache"; } MyDataGrid.DataSource=Source; MyDataGrid.DataBind(); } Caching Data A

17 Building Applications using ASP.NET and C# / Session 15 / 17 of 17 Data Caching - 3


Download ppt "Building Applications using ASP.NET and C# / Session 15 / 1 of 17 Sessio n 15."

Similar presentations


Ads by Google