1
<%@ OutputCache Duration="60" VaryByParam="none" %>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head runat="server">
5
<title>Substitution控件演示示例</title>
6
</head>
7
8
<script runat="server" language="C#">
9
public void Page_Load(object sender, System.EventArgs e)
10
{
11
CachedDateLabel.Text = DateTime.Now.ToString();
12
}
13
public static string GetCurrentDateTime(HttpContext context)
14
{
15
return DateTime.Now.ToString();
16
}
17
</script>
18
19
<body>
20
<form id="form1" runat="server">
21
<div>
22
<p>
23
下面的时间显示没有使用缓存功能</p>
24
<asp:Substitution ID="Substitution2" MethodName="GetCurrentDateTime" runat="Server">
25
</asp:Substitution>
26
<br />
27
<p>
28
下面的时间显示使用了缓存功能,只有在60秒后才改变</p>
29
<asp:Label ID="CachedDateLabel" runat="Server"></asp:Label>
30
<br />
31
<br />
32
<asp:Button ID="RefreshButton" Text="刷新页面" runat="Server"></asp:Button>
33
</div>
34
</form>
35
</body>
36
</html>
37

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

当执行以上页面时,总是报错:“以一种访问权限不允许的方式作了一个访问套接字的尝试。”我查看了我的Visual Studio 2005的基本配置,包括权限等内容,均没有问题。我想这是不是Visual Studio 2005 beta2的bug呢?大家来试验并讨论一下,希望共同进步。