1

I am struggling to get my LogIn/Registering system working. I have a register.aspx page in which a user signs up and all this data is entered into a database, Then I have a Login.aspx where the user should put in their username and password.

But I cannot even seem to get to this stage as authentication seems to keep messing up.

<authentication mode="Forms">
  <forms name="401kApp" loginUrl="/login.aspx"
         defaultUrl="Home.aspx"
         />
</authentication>

I want my authentication to realise nobody is signed in (because they shouldn't be unless they sign in on the login page themselves). But for some reason it seems to keep redirecting me and I am often getting HTTP 404: Resource cannot be found.

It redirects to:

http://localhost:52761/login.aspx?ReturnUrl=%2f

I have no idea why it does this as it wont even load the login or register page to let me login when the authentication is on.

This is my login code:

<asp:LoginStatus id="LoginStatus1" runat="server"></asp:LoginStatus>
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
Please log in.
</AnonymousTemplate>
<LoggedInTemplate>
Thanks for logging in 
</LoggedInTemplate>
</asp:LoginView>              

Can anyone help me?

Thanks in advance

1
  • I am now struggling as it permanently says I am logged in. When I have not actually logged in at any point using the login screen. So the redirect problem has been solved but the Login Problem has not. Commented Nov 1, 2011 at 21:09

2 Answers 2

4

You need to add a 'location' section to your web.config which will let 'register.aspx' to be accessed anonymously. otherwise when a user tries to access it they will get redirected to the login page to get authenticated:

<location path="/account/register.aspx">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>

more info:location Element (ASP.NET Settings Schema)

Sign up to request clarification or add additional context in comments.

6 Comments

I have tried this and it still trys to redirect me when I click on register or Login: localhost:52761/login.aspx?ReturnUrl=%2fAccount%2fRegister.aspx Saying HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
it appears that your register page is in a subdirectory called account... location path property needs to represent the path you want unsecured.... perhaps "/Account/Register.aspx", i will update my sample
Thank you very much, Yes that has solved the redirect problem, However it is now saying I am logged in even though I have not logged in via the Login.aspx page. I have cleared the cache and closed the session and it is still saying I am logged in. Any ideas?
not sure what you mean by "it is saying i'm logged in". you're not , are you? if you try to hit your home page you get challenged right?
Well in the top section it says: [Logout] Thanks for logging in This must be because of the <LoggedInTemplate> Thanks for logging in </LoggedInTemplate>
|
0

Do you have the Login.aspx page in your application root?

If you check your web.config you should see a section which pertains to the Membership Provider (which you seem to be using) where you can specify the login page if it's called something different to login.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.