当前位置:网站首页>State management uses session to restrict page access. Only login can verify sessionlogin Aspx can access session aspx
State management uses session to restrict page access. Only login can verify sessionlogin Aspx can access session aspx
2022-06-29 21:50:00 【Eighty eight old】
First visit Session Jump to on page SessionLogin page
Session.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Session.aspx.cs" Inherits="Chap2_Session" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblMsg" runat="server" ></asp:Label>
</div>
</form>
</body>
</html>
Session.aspx.cs
using System;
public partial class Chap2_Session : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Session["Name"]!=null)
{
lblMsg.Text = Session["Name"] + ", Welcome !";
}
else
{
Response.Redirect("~/Chap2/SessionLogin.aspx");
}
}
}
SessionLogin.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SessionLogin.aspx.cs" Inherits="Chap2_SessionLogin" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
user name :<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<br />
password :<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
<br />
<asp:Button ID="btnSubmit" runat="server" Text=" confirm " OnClick="btnSubmit_Click" />
</form>
</body>
</html>
SessionLogin.aspx.cs
using System;
public partial class Chap2_SessionLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
// Comparison between the actual project and the data stored in the database
if (txtName.Text == "leaf" && txtPassword.Text == "111")
{
// assignment
Session["Name"] = "leaf";
}
}
}
边栏推荐
- Huawei cloud AOM version 2.0 release
- Houdini graphic notes: VAT (3.0) import ue4/5 setup wizard [official document translation]
- A. Beat The Odds
- Goahead translation - Active Server Pages
- Realize inotify and Rsync real-time backup
- Résumé du projet de petite bibliothèque
- leetcode:238. 除自身以外数组的乘积
- Layer 3 loop brought by route Summary - solution experiment
- 状态管理 利用Session限制页面访问 只有通过登录验证SessionLogin.aspx才能访问Session.aspx
- leetcode:724. Find the central subscript of the array
猜你喜欢

什么是 SYN 洪水攻击?如何防护?

【ROS进阶篇】第四讲 ROS中的重名问题(节点、话题与参数)

leetcode:307. 区域和检索 - 数组可修改

Summary of document level symbols under different systems

数字密码锁verilog设计+仿真+上板验证

About Effect Size

STM32最小系统搭建(原理图)

一颗新的北极星已经升起!

Hardware development notes (VIII): basic process of hardware development, making a USB to RS232 module (VII): creating a basic dip component (crystal oscillator) package and associating the principle

Flame retardant test of aluminum sheet as/nzs 1530.1 non combustible materials
随机推荐
[crossbeam series] 5 crossbeam util and crossbeam queue: some practical gadgets
leetcode:307. 区域和检索 - 数组可修改
leetcode:724. 寻找数组的中心下标
How to use the DVD entry level in taro3.*
How can colleges and universities build future oriented smart campus based on cloud native? Full stack cloud native vs traditional technology architecture
How to use SMS to deliver service information to customers? The guide is here!
透过华为军团看科技之变(五):智慧园区
leetcode:724. Find the central subscript of the array
Viewing technological changes through Huawei Corps (V): smart Park
Basic qualities of management personnel
Summary of document level symbols under different systems
What is unique about MES system?
Hardware development notes (VIII): basic process of hardware development, making a USB to RS232 module (VII): creating a basic dip component (crystal oscillator) package and associating the principle
Flutter technology and Practice (2)
唯品会商品详情API接口(item_get-获得唯品会商品详情接口),唯品会详情API接口
American tunneling ASTM E84 surface flame retardant test
Datakit acts as an API server for local data acquisition
The explain function of the DALEX package of R language generates a machine learning model interpreter and predict for the specified classification prediction_ The parts function analyzes the contribu
Which brokerage commission is the lowest and safest
Résumé du projet de petite bibliothèque