Design ASP.NET Pages for Performance improvement using Caching.

Aspx:

<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="PR8A.aspx.cs"Inherits="WebApplication1.PR8A"%>

<%@OutputCacheDuration="20"VaryByParam="textbox1"%>

 

<!DOCTYPEhtml>

 

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title></title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:TextBoxID="TextBox1"runat="server"OnTextChanged="TextBox1_TextChanged"></asp:TextBox>

<br/><br/>

<asp:ButtonID="Button1"runat="server"Text="Demo of Output cache"OnClick="Button1_Click"/>

</div>

</form>

</body>

</html>

 

Aspx.cs

using System;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Web;

usingSystem.Web.UI;

usingSystem.Web.UI.WebControls;

usingSystem.Threading;

 

namespace WebApplication1

{

publicpartialclassPR8A : System.Web.UI.Page

    {

protectedvoidPage_Load(object sender, EventArgs e)

        {

Thread.Sleep(20000);

Response.Write("this page was generated and cached at:" + DateTime.Now.ToString());

 

        }

 

protectedvoid Button1_Click(object sender, EventArgs e)

        {

Response.Write("<br><br>");

Response.Write("<h1>Welcome:" + this.TextBox1.Text + "</h1>");

 

        }

protectedvoid TextBox1_TextChanged(object sender, EventArgs e)

        {

 

        }

 }

}

 

OUTPUT:

Design ASP.NET Pages for Performance improvement using Caching.

Design ASP.NET Pages for Performance improvement using Caching.

Post a Comment

0 Comments