当前位置:网站首页>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";
}
}
}
边栏推荐
- As a developer, you need to know about the codeless development platform IVX
- JD alliance API - universal chain transfer interface - Jingpin library interface - Interface Customization
- STM32 and gd32 notes
- Huawei cloud AOM version 2.0 release
- After inventing anti-virus software, he chose to be a top-notch gangster
- My creation anniversary
- 铝板AS/NZS 1530.1 不燃性材料的阻燃测试
- Amazon Keyword Search API interface (item_search- Amazon product search interface by keyword), Amazon API interface
- Goahead webserver migration
- verilog实现DDS波形发生器模块,可实现频率、相位可调,三种波形
猜你喜欢

VHDL电话计费系统设计

leetcode:238. Product of arrays other than itself

Reading notes on how to connect the network - LAN on the server side (4)

STM32 and gd32 notes

Summer Challenge harmonyos ark development framework arkui streamer button effect

【ROS进阶篇】第二讲 自定义头、源文件封装

Water polo chart - using dynamic ripples to show percentages

Vipshop product details API interface (item_get- get vipshop product details interface), vipshop details API interface

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

不同系统下的文件层级符号小结
随机推荐
数字密码锁verilog设计+仿真+上板验证
知识蒸馏(Knowledge Distilling)学习笔记
Bs-gx-018 student examination system based on SSM
【ROS进阶篇】第四讲 ROS中的重名问题(节点、话题与参数)
Taro2.* applet configuration sharing wechat circle of friends
什么是 SYN 洪水攻击?如何防护?
Verilog implements DDS waveform generator module, which can realize adjustable frequency and phase, three waveforms
Live broadcast preview | PostgreSQL kernel Interpretation Series Lecture 1: overview of PostgreSQL system
flutter BottomNavigationBar切换页面保持状态
期末实训 简单通讯录 c语言
一次 Keepalived 高可用的事故,让我重学了一遍它!
Datakit acts as an API server for local data acquisition
Win10 add SSH public key
PostgreSQL每周新闻—6月22日
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
Flutter technology and Practice (2)
Redis (I) -- getting started with redis (1) -- redis introduction, installation and startup, and common configurations
Win10添加ssh公钥
Golang operation etcd
唯品会商品详情API接口(item_get-获得唯品会商品详情接口),唯品会详情API接口