Problems Redirecting from a Login Page

Discussion in 'ASP .Net' started by Gary Coutts, Dec 6, 2005.

  1. Gary Coutts

    Gary Coutts Guest

    Hi,

    I am have problems redirecting from a login page. The login page is simple,
    with just 2 textboxes and one button. On the button click the routine below
    is called:

    I am using:
    Visual Studio 2003 Version 7.1.3008
    Framework 1.1 Version 1.1.4322 SP1
    Windows XP Pro Version 2002 SP2

    I have tried two ways:

    protected void LoginUser(Object s,EventArgs e)
    {

    if(FormsAuthentication.Authenticate(Username.Text,Password.Text))
    {

    -------- First Way------------
    // Redirect to requested URL, or homepage if no previous page
    requested
    string returnUrl = Request.QueryString["ReturnUrl"];

    if (returnUrl == null)
    returnUrl = "Home.aspx";

    Response.Redirect(returnUrl);

    -------- Second Way------------
    FormsAuthentication.RedirectFromLoginPage(Username.Text,true) ;
    }
    }

    Below is part of the Web.config for authentication and authorization

    <authentication mode="Forms">

    <forms name=".LoginCookie" loginUrl="login.aspx" protection="All"
    timeout="40" path="/">

    <credentials passwordFormat="Clear">

    <user name="gwc" password="qfbxra"></user>

    </credentials>

    </forms>

    </authentication>



    <authorization>

    <allow users="?"></allow>

    <deny users="*"></deny> <!-- Used to override <allow
    users="*"></allow> in machine.config-->


    </authorization>

    I searched the web about this problems and have not found any solutions
    that work.

    Does anyone have any suggestions as I am losing the will to live





    Cheers

    gwc
    Gary Coutts, Dec 6, 2005
    #1
    1. Advertising

  2. In Web.config, it should be

    <authorization>
    <deny users="?" /> <!-- deny anonymous users, otherwise
    FormsAuthentication object never works -- >
    <allow users="*" /> <!-- Used to override -->
    </authorization>


    HTH

    Elton Wang

    "Gary Coutts" wrote:

    > Hi,
    >
    > I am have problems redirecting from a login page. The login page is simple,
    > with just 2 textboxes and one button. On the button click the routine below
    > is called:
    >
    > I am using:
    > Visual Studio 2003 Version 7.1.3008
    > Framework 1.1 Version 1.1.4322 SP1
    > Windows XP Pro Version 2002 SP2
    >
    > I have tried two ways:
    >
    > protected void LoginUser(Object s,EventArgs e)
    > {
    >
    > if(FormsAuthentication.Authenticate(Username.Text,Password.Text))
    > {
    >
    > -------- First Way------------
    > // Redirect to requested URL, or homepage if no previous page
    > requested
    > string returnUrl = Request.QueryString["ReturnUrl"];
    >
    > if (returnUrl == null)
    > returnUrl = "Home.aspx";
    >
    > Response.Redirect(returnUrl);
    >
    > -------- Second Way------------
    > FormsAuthentication.RedirectFromLoginPage(Username.Text,true) ;
    > }
    > }
    >
    > Below is part of the Web.config for authentication and authorization
    >
    > <authentication mode="Forms">
    >
    > <forms name=".LoginCookie" loginUrl="login.aspx" protection="All"
    > timeout="40" path="/">
    >
    > <credentials passwordFormat="Clear">
    >
    > <user name="gwc" password="qfbxra"></user>
    >
    > </credentials>
    >
    > </forms>
    >
    > </authentication>
    >
    >
    >
    > <authorization>
    >
    > <allow users="?"></allow>
    >
    > <deny users="*"></deny> <!-- Used to override <allow
    > users="*"></allow> in machine.config-->
    >
    >
    > </authorization>
    >
    > I searched the web about this problems and have not found any solutions
    > that work.
    >
    > Does anyone have any suggestions as I am losing the will to live
    >
    >
    >
    >
    >
    > Cheers
    >
    > gwc
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    =?Utf-8?B?RWx0b24gVw==?=, Dec 7, 2005
    #2
    1. Advertising

  3. Gary Coutts

    Gary Coutts Guest

    Hi Elton,

    Thanks for the reply.

    My mistake my web.config should have read

    <deny users="?" /> <!-- deny anonymous users, otherwise

    I had been playing around and forgot to return to the original config.


    I tried replacing the

    <deny users="*"/>

    with your suggested

    <allow users="*"/>

    but now it gives me access to any of the page without going to the login
    page.

    Cheers

    Gary


    "Elton W" <> wrote in message
    news:...
    > In Web.config, it should be
    >
    > <authorization>
    > <deny users="?" /> <!-- deny anonymous users, otherwise
    > FormsAuthentication object never works -- >
    > <allow users="*" /> <!-- Used to override -->
    > </authorization>
    >
    >
    > HTH
    >
    > Elton Wang
    >
    > "Gary Coutts" wrote:
    >
    >> Hi,
    >>
    >> I am have problems redirecting from a login page. The login page is
    >> simple,
    >> with just 2 textboxes and one button. On the button click the routine
    >> below
    >> is called:
    >>
    >> I am using:
    >> Visual Studio 2003 Version 7.1.3008
    >> Framework 1.1 Version 1.1.4322 SP1
    >> Windows XP Pro Version 2002 SP2
    >>
    >> I have tried two ways:
    >>
    >> protected void LoginUser(Object s,EventArgs e)
    >> {
    >>
    >> if(FormsAuthentication.Authenticate(Username.Text,Password.Text))
    >> {
    >>
    >> -------- First Way------------
    >> // Redirect to requested URL, or homepage if no previous page
    >> requested
    >> string returnUrl = Request.QueryString["ReturnUrl"];
    >>
    >> if (returnUrl == null)
    >> returnUrl = "Home.aspx";
    >>
    >> Response.Redirect(returnUrl);
    >>
    >> -------- Second Way------------
    >> FormsAuthentication.RedirectFromLoginPage(Username.Text,true) ;
    >> }
    >> }
    >>
    >> Below is part of the Web.config for authentication and authorization
    >>
    >> <authentication mode="Forms">
    >>
    >> <forms name=".LoginCookie" loginUrl="login.aspx" protection="All"
    >> timeout="40" path="/">
    >>
    >> <credentials passwordFormat="Clear">
    >>
    >> <user name="gwc" password="qfbxra"></user>
    >>
    >> </credentials>
    >>
    >> </forms>
    >>
    >> </authentication>
    >>
    >>
    >>
    >> <authorization>
    >>
    >> <allow users="?"></allow>
    >>
    >> <deny users="*"></deny> <!-- Used to override <allow
    >> users="*"></allow> in machine.config-->
    >>
    >>
    >> </authorization>
    >>
    >> I searched the web about this problems and have not found any solutions
    >> that work.
    >>
    >> Does anyone have any suggestions as I am losing the will to live
    >>
    >>
    >>
    >>
    >>
    >> Cheers
    >>
    >> gwc
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    Gary Coutts, Dec 7, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vijay
    Replies:
    3
    Views:
    1,467
    Saravana [MVP]
    Nov 4, 2003
  2. Pradeep Pise
    Replies:
    0
    Views:
    521
    Pradeep Pise
    Jul 9, 2004
  3. =?Utf-8?B?S2FseWFuaQ==?=

    Redirecting to login page from a popup window.

    =?Utf-8?B?S2FseWFuaQ==?=, Jun 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    851
    =?Utf-8?B?c3Jpbmk=?=
    Jun 21, 2005
  4. WhiskyRomeo

    redirecting from another page besides the login page

    WhiskyRomeo, Jan 18, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    103
    WhiskyRomeo
    Jan 18, 2005
  5. Replies:
    1
    Views:
    125
    ccc31807
    Mar 24, 2008
Loading...

Share This Page