Avatar of VeeVan
VeeVan

asked on 

aspx Login not working in Internet Explorer

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

C#ASP.NET.NET Programming

Avatar of undefined
Last Comment
VeeVan
Avatar of VeeVan
VeeVan

ASKER

Well, it appears I lied. The code ONLY works in Chrome. Not in FF. and definitely NOT in IE.
Help!
Avatar of HainKurt
HainKurt
Flag of Canada image

"it is stuck on the login page": any error code? whats happening?
ASKER CERTIFIED SOLUTION
Avatar of VeeVan
VeeVan

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of VeeVan
VeeVan

ASKER

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.
Avatar of VeeVan
VeeVan

ASKER

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.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo