上下文context
如何才能在应用程序的每页中添加标准页眉和页脚?
void Application_BeginRequest(Object sender, EventArgs e) {
// 生成页眉
Context.Response.Write("<html>\n<body bgcolor=#efefef>\n<hr>\n");
}
void Application_EndRequest(Object sender, EventArgs e) {
// 生成页脚
Context.Response.Write("<hr>\2002 Microsoft Corporation 版权所有\n");
Context.Response.Write("</body>\n</html>");
}
void Application_BeginRequest(Object sender, EventArgs e) {
// 生成页眉
Context.Response.Write("<html>\n<body bgcolor=#efefef>\n<hr>\n");
}
void Application_EndRequest(Object sender, EventArgs e) {
// 生成页脚
Context.Response.Write("<hr>\2002 Microsoft Corporation 版权所有\n");
Context.Response.Write("</body>\n</html>");
}
如何在用户经过身份验证后显示欢迎信息?
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e) {
if (User.Identity.IsAuthenticated) {
welcome.Text = "欢迎" + User.Identity.Name;
}
else {
// 尚未登录,添加一个指向登录页的链接
welcome.Text = "请登录!";
welcome.NavigateUrl = "signin.aspx";
}
}
</script>
<asp:HyperLink id="welcome" runat="server" maintainstate="false">
</asp:HyperLink>
lemon

浙公网安备 33010602011771号