Question

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

Was it helpful?

Solution

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)

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top