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

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

  1. Open Visual Studio .NET.
  2. 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.

  1. In Solution Explorer, open the Web.config file.
  2. Change the authentication mode to Forms.
  3. 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> 
    
  4. Deny access to the anonymous user in the <authorization> section as follows:
    <authorization>
       <deny users ="?" />
       <allow users = "*" />
    </authorization>

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(216)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.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
点击右上角即可分享
微信分享提示