How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C#.NET
How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C#.NET
This article refers to the following Microsoft .NET Framework Class Library namespaces:
- System.Data.SqlClient
- System.Web.Security
IN THIS TASK
- SUMMARY
-
- Requirements
- Create an ASP.NET Application Using Visual C# .NET
- Configure the Security Settings in the Web.config File
- Create a Sample Database Table to Store Users Details
- Create a Logon.aspx Page
- Code the Event Handler So That It Validates the User Credentials
- Create a Default.aspx Page
- Additional Notes
- REFERENCES
ummary
This article demonstrates how to implement forms-based authentication by using a database to store the users.
Requirements
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:- Microsoft Visual Studio .NET
- Microsoft Internet Information Services (IIS) version 5.0 or later
- Microsoft SQL Server
Create an ASP.NET Application Using C# .NET
- Open Visual Studio .NET.
- Create a new ASP.NET Web application, and specify the name and location.
Configure the Security Settings in the Web.config File
This section demonstrates how to add and modify the <authentication> and <authorization> configuration sections to configure the ASP.NET application to use forms-based authentication.
- In Solution Explorer, open the Web.config file.
- Change the authentication mode to Forms.
- Insert
the <Forms> tag, and fill the appropriate attributes. (For more
information about these attributes, refer to the MSDN documentation or
the QuickStart documentation that is listed in the
REFERENCES section.) Copy the following code, and then click Paste as HTML on the
Edit menu to paste the code in the <authentication> section of the file:<authentication mode="Forms"> <forms name=".ASPXFORMSDEMO" loginUrl="logon.aspx" protection="All" path="/" timeout="30" /> </authentication>
- Deny access to the anonymous user in the <authorization> section as follows:
<authorization> <deny users ="?" /> <allow users = "*" /> </authorization>
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2019-06-30 jQuery file upload上传图片的流程
2019-06-30 chrome查看JavaScript的堆栈调用
2019-06-30 JavaScript apply
2019-06-30 chrome 调试
2019-06-30 jQuery file upload上传图片出错分析
2019-06-30 jQuery插件开发
2019-06-30 js2flowchart