asp.net 票據(jù)簡單應(yīng)用
更新時間:2009年03月21日 00:12:24 作者:
asp.net票據(jù)應(yīng)用實例代碼。
復(fù)制代碼 代碼如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace www
{
public partial class piaoju1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//設(shè)置用戶登錄標(biāo)志,與瀏覽器關(guān)聯(lián),失效條件是瀏覽器關(guān)閉
protected void btnSet_Click(object sender, EventArgs e)
{
System.Web.Security.FormsAuthentication.SetAuthCookie("uName,uPower", false);
}
//取得用戶名
protected void btnGet_Click(object sender, EventArgs e)
{
Response.Write(HttpContext.Current.User.Identity.Name);
}
//退出
protected void btnLogout_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
}
//判斷是否登錄
protected void btnShow_Click(object sender, EventArgs e)
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
Response.Write("ok");
else
Response.Write("no");
}
}
}
復(fù)制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="piaoju1.aspx.cs" Inherits="www.piaoju1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>票據(jù)的簡單使用</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnShow" runat="server" Text="show" OnClick="btnShow_Click" />
<asp:Button ID="btnSet" runat="server" Text="set" OnClick="btnSet_Click" />
<asp:Button ID="btnGet" runat="server" Text="get" OnClick="btnGet_Click" />
<asp:Button ID="btnLogout" runat="server" Text="out" OnClick="btnLogout_Click" />
</div>
</form>
</body>
</html>
相關(guān)文章
asp.net 驗證字符串是否為純數(shù)字檢測函數(shù)
如何驗證字符串是否為純數(shù)字2010-03-03ajax添加數(shù)據(jù)后如何在網(wǎng)頁顯示
這篇文章主要介紹了ajax添加數(shù)據(jù)顯示在網(wǎng)頁上,此文是通過ajax獲取后臺json數(shù)據(jù)來實現(xiàn)此功能,需要的朋友可以參考下2015-07-07VS 2015開發(fā)跨平臺手機(jī)應(yīng)用的配置教程
這篇文章主要給大家介紹了關(guān)于VS 2015開發(fā)跨平臺手機(jī)應(yīng)用配置的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-12-12輕量級ORM框架Dapper應(yīng)用之返回多個結(jié)果集
這篇文章介紹了使用Dapper返回多個結(jié)果集的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-03-03asp.net在Repeater嵌套的Repeater中使用復(fù)選框詳解
這篇文章主要介紹了asp.net在Repeater嵌套的Repeater中使用復(fù)選框,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12ASP.NET?Core使用EF創(chuàng)建模型(包含屬性、排除屬性、主鍵和生成值)
這篇文章介紹了ASP.NET?Core使用EF創(chuàng)建模型的的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04