Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM Computer
01-Jun-2025To enable Forms Authentication in your ASP.NET application's
web.configfile, you need to configure the<authentication>and<authorization>sections. Here’s how you do it:Basic Setup to Enable Forms Authentication
Add the following inside the
<system.web>section of yourweb.config:Explanation:
<authentication mode="Forms">: This tells ASP.NET to use Forms Authentication.<forms loginUrl="~/Login.aspx" timeout="30" />:loginUrlspecifies the path to the login page where unauthenticated users will be redirected.timeoutsets the expiration time (in minutes) for the authentication ticket.<authorization>section:<deny users="?" />denies access to all anonymous (not logged in) users.Optional configurations you can add inside
<forms>:name: the name of the authentication cookie (default is.ASPXAUTH).path: the cookie path (default is/).requireSSL="true": forces the cookie to be sent over HTTPS only.slidingExpiration="true": refreshes the cookie expiration time on each request.