Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

How to redirect user to login page if the user is not login in web forms authentication

$
0
0

here is my web.config

<system.web><compilation debug="true" targetFramework="4.5" /><authentication mode="Forms"><forms defaultUrl="Timeline.aspx" loginUrl="~/Account/login.aspx" slidingExpiration="true" timeout=" 20 " /></authentication><authorization><deny users="?" /></authorization></system.web><location path="Timeline.aspx" /><location path="~/Account/ChangePassword.aspx"><system.web><authorization><allow users="?" /></authorization></system.web></location><location path="Timeline.aspx" /><location path="~/Account/Register.aspx" /></configuration>

code on landing page

protected void Page_Load(object sender, EventArgs e)
    {

        if (this.Page.User.Identity.IsAuthenticated)
        {
            string username = this.Page.User.Identity.Name;
            Getbanner(username);
        }
    }


    public void Getbanner(string username)

if user wants to view Timeling page and the user didnt login redirect to login


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>