service.aspx
来自「C#开发者可使用的经典案例集,源自于ASP.NET经典范例50讲」· ASPX 代码 · 共 46 行
ASPX
46 行
<html>
<head>
<title>Cookie应用举例</title>
<script Language="C#" runat="server">
void Page_Load()
{
try
{
Hashtable loginUser = HashFile.ReadHashtableFromFile(Server.MapPath("login.txt"));
HttpCookie CookieUser = Request.Cookies["user"];
if( CookieUser == null )
{
Response.Redirect("Login.aspx");
return;
}
else if( (string)loginUser[CookieUser.Value] != Request.Cookies["id"].Value )
{
Response.Redirect("Login.aspx");
return;
}
}
catch(System.Threading.ThreadAbortException e)
{
}
catch(Exception e)
{
Response.Write(e.ToString());
Response.End();
return;
}
}
</script>
</head>
<body>
<h3>登录成功!</h3>
<hr />
选择您需要的服务:
<ol>
<li><a href="mailto:nobody@nobody.com">发送邮件</a>
<li><a href="http://news.sina.com.cn">查看新闻</a>
<li><a href="http://game.sina.com.cn">在线游戏</a>
<li><a href="logout.aspx">注销</a>
</ol>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?