关于asp.net2.0中缓存页面的部分数据(Request.UserHostAddress.ToString(),就是客户端的IP不同反映的欢迎信息不同)需要实时变化的问题想在一个页面中,只把Request.UserHostAddress.ToString()实时显示,并且输出到页面上,其他的内容都缓存起来,任何浏览用户看的都是一样。请问应该怎么设置?谢谢大家!
解决方案 »
- TreeView控件选择变色问题(第二次提出)
- 求助求助无限分级的问题
- 请问下,这段源码是什么意思?
- detailsview在插入状态时,如何才能以codebehind的方式给一个文本框赋值?
- 关于复杂打印设置的问题! 求高手解答!
- 80分求教 checkboxlist的 客户端颜色显示问题
- 新手求助,在线等.....
- 无法打开文件 D:\Site\jhyd\tmpFile.gif 以进行导出。
- 求救:那里有关于RTML方面的资料和资源!
- 为什么inherits system.web.ui.itemplate是错的?怎样才对呢?
- 关于实时消息的及时接受问题
- 基于角色的Forms验证,内有代码,帮忙看看哪写错了,为什么一直都验证不了???顶者有分
web 用户控件来解决。最好在.aspx 或者 .CS中解决。
<script runat="server" language="C#">
void Page_Load(object sender, System.EventArgs e)
{
// Programmatically create a Substitution control.
Substitution Substitution1 = new Substitution();
// Specify the callback method.
Substitution1.MethodName = "GetCurrentDateTime";
// Add the Substitution control to the controls
// collection of PlaceHolder1.
PlaceHolder1.Controls.Add (Substitution1); // Display the current date and time in the label.
// Output caching applies to this section of the page.
CachedDateLabel.Text = DateTime.Now.ToString();
}
// The Substitution control calls this method to retrieve
// the current date and time. This section of the page
// is exempt from output caching.
public static string GetCurrentDateTime (HttpContext context)
{
return DateTime.Now.ToString ();
}
</script><html>
<head id="Head1" runat="server">
<title>Substitution Class Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>Substitution Constructor Example</h3>
<p>This section of the page is not cached:</p>
<asp:placeholder id="PlaceHolder1"
runat="Server">
</asp:placeholder>
<br />
<p>This section of the page is cached:</p>
<asp:label id="CachedDateLabel"
runat="Server">
</asp:label>
<br /><br />
<asp:button id="RefreshButton"
text="Refresh Page"
runat="Server">
</asp:button> </form>
</body>
</html>已经解决谁来接分。