Response.ReDirect / FormsAuth.ForwardFromLogin not working

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Re: Response.ReDirect / FormsAuth.ForwardFromLogin not working

    Instead of doing :-

    FormsAuthentication.SetAuthCookie
    (txtUserName.Text,false);
    Response.Redirect
    ("http://www.appliedbioscience.co.uk/appliedbioscience/ind
    ex.aspx",false); //fails here

    try doing :-

    FormsAuthentication.RedirectFromLoginPage(txtUserN ame.Text,false);

    and see what happens.


    --
    - Paul Glavich
    Microsoft MVP - ASP.NET


    "Matthew Owens via .NET 247" <anonymous@dotnet247.com> wrote in message
    news:eFn57HDtEHA.1468@TK2MSFTNGP12.phx.gbl...
    > Hi,
    >
    > I have a login page which does not redirect the user once
    > the code has been executed, see below. Whats strange is
    > it works perfectly on my localhost when debugging,
    > however it fails to redirect when depolyed to a remote
    > server. Am I missing any IIS settings or anything? The
    > login page just reloads back to itself once the login button has been
    > clicked.
    >
    > Code for the login button:
    >
    > private void _btnLogin_Click(object sender,
    > System.Web.UI.ImageClickEventArgs e)
    > {
    > if (IsValidUser(txtUserName.Text,
    > txtPassword.Text)) //interacts with the database. This
    > method is fine
    > {
    > if(FormsAuthentication.GetRedirectUrl
    > (txtUserName.Text,false)=="/appliedbioscience/index.aspx")
    > {
    > FormsAuthentication.SetAuthCookie
    > (txtUserName.Text,false);
    > Response.Redirect
    > ("http://www.appliedbioscience.co.uk/appliedbioscience/ind
    > ex.aspx",false); //fails here
    > }
    > else if
    > ((FormsAuthentication.GetRedirectUrl
    > (txtUserName.Text,false).ToUpper().IndexOf("ADMIN" ) != -
    > 1) && (string)Session["Role"]!="admin")
    > phMsg.Controls.Add(new
    > LiteralControl("<font color=red>ERROR: You do not have
    > the necessary privellages to administrate this
    > site</font>"));
    > else
    >
    > FormsAuthentication.RedirectFromLoginPage
    > (txtUserName.Text,false); //fails here too
    > }
    > else
    > {
    > phMsg.Controls.Add(new LiteralControl
    > ("<font color=red>ERROR: Invalid Username /
    > Password</font>"));
    > }
    > }
    >
    > Thanks,
    > Matt
    >
    > -----------------------
    > Posted by a user from .NET 247 ([url]http://www.dotnet247.com/[/url])
    >
    > <Id>2lDQndDYrkKxWzYTDB1qwA==</Id>

    Paul Glavich [MVP - ASP.NET] Guest

  2. Similar Questions and Discussions

    1. response.redirect to an HTTPS not working
      I have a web from that based on the user's response needs to go to a web folder set up with SSL. My problem is that when the redirect is executed I...
    2. Response.Flush / Response.Redirect
      Hi, I've had a good google and can't find anything already on this so : I'm currently trying to have a 'Page Loading' page on a site. The way...
    3. Response.redirect only working sometimes
      I have response.redirect("/home.asp") in my code but instead of redirecting to that page it sometimes redirects to the current page...
    4. Response.Write and Response.Redirect
      On my Page_Load event, i need to do some validation and then either let them proceed, or display a error message and boot them back to the previous...
    5. Redirect to New Browser Window like Response.Redirect
      That worked just fine for me as long as you put that open statement on one line rather than 2. "michel" <michely3k@yahoo.com> wrote in...
  3. #2

    Default RE: Response.ReDirect / FormsAuth.ForwardFromLogin not working

    Hi Mathew,
    Try using another forms of Redirection!
    maybe response.redirect!
    Enjoy!
    Patrick

    "Matthew Owens via .NET 247" wrote:
    > Hi,
    >
    > I have a login page which does not redirect the user once
    > the code has been executed, see below. Whats strange is
    > it works perfectly on my localhost when debugging,
    > however it fails to redirect when depolyed to a remote
    > server. Am I missing any IIS settings or anything? The
    > login page just reloads back to itself once the login button has been
    > clicked.
    >
    > Code for the login button:
    >
    > private void _btnLogin_Click(object sender,
    > System.Web.UI.ImageClickEventArgs e)
    > {
    > if (IsValidUser(txtUserName.Text,
    > txtPassword.Text)) //interacts with the database. This
    > method is fine
    > {
    > if(FormsAuthentication.GetRedirectUrl
    > (txtUserName.Text,false)=="/appliedbioscience/index.aspx")
    > {
    > FormsAuthentication.SetAuthCookie
    > (txtUserName.Text,false);
    > Response.Redirect
    > ("http://www.appliedbioscience.co.uk/appliedbioscience/ind
    > ex.aspx",false); //fails here
    > }
    > else if
    > ((FormsAuthentication.GetRedirectUrl
    > (txtUserName.Text,false).ToUpper().IndexOf("ADMIN" ) != -
    > 1) && (string)Session["Role"]!="admin")
    > phMsg.Controls.Add(new
    > LiteralControl("<font color=red>ERROR: You do not have
    > the necessary privellages to administrate this
    > site</font>"));
    > else
    >
    > FormsAuthentication.RedirectFromLoginPage
    > (txtUserName.Text,false); //fails here too
    > }
    > else
    > {
    > phMsg.Controls.Add(new LiteralControl
    > ("<font color=red>ERROR: Invalid Username /
    > Password</font>"));
    > }
    > }
    >
    > Thanks,
    > Matt
    >
    > -----------------------
    > Posted by a user from .NET 247 ([url]http://www.dotnet247.com/[/url])
    >
    > <Id>OefijW+jmUCo6aXadH2FPg==</Id>
    >
    Patrick.O.Ige Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139