I am working on asp.net entity framework. I want to access the pages only through login and not directly by entering the URL of the page. If user enters the URL of the page and tries to access it then he should be redirected to Login Page. How can I do that? User are supposed to login with username and password from DB. I am new to ASP.NET
The functionality you are looking for can be achieved by adding the following authentication/authorization sections to the ASP.NET Web.config
file like shown in the following example:
<system.web>
<authentication mode="Forms">
<forms name="SomeName"
loginUrl="Login.aspx"
protection="All"
path="/">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
It essentially denies all access for unauthenticated Users: if such unauthenticated User tries to access any page at your website, then he/she will be redirected to the Login.aspx
page ( details at MSDN https://msdn.microsoft.com/en-us/library/wce3kxhd.aspx, https://msdn.microsoft.com/en-us/library/xdt4thhy.aspx).
Hope this will help.