views:

380

answers:

5

Just starting out in asp.net. Have just created a login.aspx page in my site and stuck on a asp login control - that's all I did. Now my Welcome.aspx page won't show as the start page of my site when I debug - even though it is set as this. Plus I have even edited my web.config - (see below) - and it still does the same thing. How do I make it work so I have my Welcome.aspx page start up as default?

<authentication mode="Forms">
      <forms defaultUrl="~/Welcome.aspx" loginUrl="~/login.aspx" timeout="1440" ></forms>
</authentication>
+3  A: 

that's because you're accessing the site with a user that has not been authenticated-- so the framework is redirecting you to the loginurl.

Stephen Wrighton
+1  A: 

You've set the login URL in web.config. You get sent to welcome.aspx, but that sees that you're not logged in -- so it bounces you back to login. If your login page has a "remember me" checkbox, try checking that off and logging in -- subsequent runs should let you right in to welcome.aspx

Danimal
A: 

Well, if the user isn't authenticated they will automatically be redirected to the "loginUrl" -- once you log in you should be redirected to Welcome.aspx, and it will be the default page as long as the credentials are valid.

Guy Starbuck
+3  A: 

If you want users to access welcome.aspx without being authenticated, put welcome.aspx in a separate folder, and set up a new web.config in that sub folder. fill out the authorization section in that web.config so that the files in that folder and subfolders will be accessible by anonymous users, like this:

<authorization><allow users="?" /></authorization>
stephenbayer
you don't need to put it into a subfolder. You can specify in the webconfig authorization levels on a per-file basis. This is important for things such as default pages, and master pages.
Stephen Wrighton
Intersting point - thanks Stephen
Vidar
I guess it's mainly by habit that I separate out my public pages from my protected pages. If You do something long enough, you think that's the only way. :)
stephenbayer
+1  A: 

There are two potential causes to your problem.

1.) The user is not authenticated, therefore they must login first. If this is the case the user will be taken to login.aspx and a returnurl parameter will exist that after login returns them to the welcome page.

2.) You are viewing the login.aspx page when you click on "debug" to start visual studio, this typically launches the currently visible page if it is an aspx page.

To get around item 1 if you DO NOT want a user to be logged in as a requirement for viewing the welcome.aspx page you can modify your authentication settings in the web.config.

Mitchel Sellers