Problem with Login control of ASP.NET

后端 未结 13 1080
春和景丽
春和景丽 2021-01-03 00:38

I set up a website to use SqlMembershipProvider as written on this page.

I followed every step. I have the database, I modified the Web.config to use this provider,

相关标签:
13条回答
  • 2021-01-03 01:18

    Try adding the path element. It must be the same as your virtual site path, for example if you test to /localhost/Authentication

    path must be = "/Authentication"

    <forms loginUrl="Login.aspx" protection="All" timeout="30" name="AuthTestCookie"
    path="/Authentication" requireSSL="false" slidingExpiration="true"
    defaultUrl="default.aspx" cookieless="UseCookies" enableCrossAppRedirects="false"/>
    
    0 讨论(0)
  • 2021-01-03 01:19

    Have you checked that the redirect path is being sent to the login form? Off my head I think it is ReturnURL?

    0 讨论(0)
  • 2021-01-03 01:20

    @Jon: I'm not using roles yet. If I check the Web Admin Tool, it says: Roles are not enabled .

    @Rob: Yes, it is there.

    I also checked the events in order: LoggingIn, Authenticate, LoggedIn, so it is following the correct path, but no redirect and it does not see that it was authenticated.

    0 讨论(0)
  • 2021-01-03 01:21

    I know this is an old post, but I found an additional answer... For others in the future with this problem, I found that my web.config file somehow had the following added to the bottom (not sure how). Once I commented the out, it worked fine :) Even though I had everything above in the file set properly, this one line caused me over an hour of headache...

    <system.webServer>
      <modules>
        <remove name="FormsAuthentication" />
      </modules>
    </system.webServer>
    
    0 讨论(0)
  • 2021-01-03 01:22

    RE: The Accepted Answer

    I do not like the hack given.

    I have a site that uses a login form called "login.aspx" and all works fine. I think we should actually find the answer rather than hack. Since all the [presumably] tested sites work. Do you not think we should actually use StackOverflow to find the ACTUAL problem? (making it much more useful than anywhere else?)

    In the LoginCtl_Authenticate event are you setting the EventArgs.Authenticated property to true?

    e.g.

    protected void LoginCtl_Authenticate(object sender, AuthenticateEventArgs e)
    {
       // Check the Credentials against DB
       bool authed = DAL.Authenticate(user, pass);
       e.Authenticated = authed;
    }
    
    0 讨论(0)
  • 2021-01-03 01:28

    What is the role of the username you are logging in with? Have you permitted this role to access Default.aspx?

    I experienced this once (a long time ago) and went "doh!" when I realized that not even admin roles can access the main folder!

    0 讨论(0)
提交回复
热议问题