Solved

aspx Login not working in Internet Explorer

Posted on 2010-11-10
6
782 Views
Last Modified: 2012-05-10
I have a side that I created in Visual Studio 2010. It has a login that protects a particular folder. I am using a CustomMembershipProvider (using SQL) for the login. In Chrome and FF, it works fine. In IE, it is stuck on the login page.

I also tried putting the code directly into the login form in the Authenticate code, and that doesn't work either.

Here is my web.config:

      <location path="Admin">
            <system.web>
      <customErrors mode="Off" />
                  <authorization>
                        <deny users="?"/>
                        <allow users="*"/>
                  </authorization>
            </system.web>
      </location>
      <system.web>
            <compilation debug="true">
                  <assemblies>
                        <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                        <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
            <authentication mode="Forms">
                  <forms name="vasWebAuthCookie" timeout="5" loginUrl="Login.aspx" defaultUrl="Admin/default.aspx" path="Admin" protection="All"/>
            </authentication>
            <membership defaultProvider="AspNetCustomMembershipProvider">
                  <providers>
                        <clear/>
                        <add name="AspNetCustomMembershipProvider" type="CustomMembershipProviderLib.CustomMembershipProvider"/>
                  </providers>
            </membership>

..... (there's a lot more....)

In the code that's written directly into the login page, it gets to the response.redirect, and looks like it processes, and does nothing.

Please help! I am desperate!


protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e)

    {

        string sConn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["vaswebcomConnectionString1"].ToString();

        SqlConnection conn = new SqlConnection(sConn);

        conn.Open();



        TextBox tUser =(TextBox) this.LoginUser.FindControl("UserName");

        TextBox tPassword = (TextBox) this.LoginUser.FindControl("Password");



        SqlCommand cmd = new SqlCommand("SELECT * FROM tblAdmin WHERE sUserID = '" + tUser.Text.ToString() +

            "' AND sPassword = '" + tPassword.Text.ToString() + "'", conn);



        SqlDataReader dr = cmd.ExecuteReader();

        if (dr.Read())

            e.Authenticated = true;

        else

            e.Authenticated = false;





        conn.Close();

        string sRedirect = Request.QueryString["ReturnURL"].ToString();

        Response.Redirect("Default.aspx", false);

    }

Open in new window

0
Comment
Question by:VeeVan
  • 4
6 Comments
 
LVL 1

Author Comment

by:VeeVan
ID: 34105110
Well, it appears I lied. The code ONLY works in Chrome. Not in FF. and definitely NOT in IE.
Help!
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 34105155
"it is stuck on the login page": any error code? whats happening?
0
 
LVL 1

Accepted Solution

by:
VeeVan earned 0 total points
ID: 34105229
Ugh. OK. I figured it out. I removed the Path attribute from the web.config forms tag and it's now saving the cookie the way it's supposed to. Sheesh.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34105235
You could try replacing these two lines:

        string sRedirect = Request.QueryString["ReturnURL"].ToString();
        Response.Redirect("Default.aspx", false)

With:

        FormsAuthentication.RedirectFromLogin();

The RedirectFromLogin makes a call to SetAuthCookie() internally, the fact that you are not setting it before redirecting may be your issue.
0
 
LVL 1

Author Comment

by:VeeVan
ID: 34105347
Sorry guys. I hate it when I post a question and then answer it right away myself, but this has been plaguing me all morning.
I appreciate the help.
0
 
LVL 1

Author Closing Comment

by:VeeVan
ID: 34134672
I figured it out. The path in forms is the path to the COOKIE, not the path to the directory. (Duh.) once i removed that, it worked fine without my juryrigged code.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now