ReDirect - Please Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Working with XP-Pro and VS.Net I have set my Start Page to "Home.aspx" but
the application always starts the "Login" page - - - How can I change the
start page to the Home.aspx???
On the login page that displays I have
private void LinkButton1_Click(object sender, System.EventArgs e)
{
bool MyVar = true;
Msg.Text = "ReDirecting to Home.aspx";
Response.Redirect("Home.aspx",MyVar);
}
AND.....
private void LinkButton2_Click(object sender, System.EventArgs e)
{
Msg.Text = "ReDirecting to Home.aspx";
Response.Redirect("Home.aspx",MyVar);
}
Using debug I see that both buttons just re-load the Login page and
re-execute the Login page Page_Load event???
WHY / HOW can I get the ReDirects to work?

I am so frustrated - please help me understand WHY these don't work.

Thanks in advance,
Paul
 
Hi Paul,

Are you running any type of authentication (Forms or Windows)? That could
keep sending people back to the login page. Good luck! Ken.
 
YES - I am using
<authentication mode="Forms" />
Does this affect "all" pages - I guess I need to do some more serious
reading...

I "thought" that if a page required security - I would code for it in the
individual pages that need it. I should be able to put up pages that do not
require security and go directly to them without validation - right?

Thanks for the clue...
Paul
 
Hi Paul,

This is a fast fix. In your Web.config use location tags like below to only
protect folders that need protecting. For home pages don't protect that.
Good luck! Ken.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<location path="Members/Administrator">
<system.web>
<authorization>
<allow roles="Administrator"></allow>
<deny users="*"/>
</authorization>
</system.web>
</location>

<location path="Members/OtherUserType">
<system.web>
<authorization>
<allow roles="UserTypeOne, UserTypeTwo"></allow>
<deny users="*"/>
</authorization>
</system.web>
</location>

<system.web>
.......

<authorization>
<allow users="*" /> <!-- Allow all users, the location tags will protect
folders. -->
</authorization>
 
Thanks Ken,
I looked at the webhost4life site and when I get closer to ready, I'll
probably sign up there. I also tried your suggestion about the web.config
file and I don't have it working (yet - with multiple 'location path'
statements) but I think you put me on the right path.
Thanks again,
Paul
 
Hi Paul,

Very cool. I use Forms Auth. with webhost4life and I use the <location>
tags for restricting access to different member roles. Remember to put the
<location> tags between the <configuration> and <system.web> tags. The
<authorization> tag should go in place of the one that is currently in your
Web.config in the <system.web> tag. The location tags below are used if you
are assigning people to roles, I figured that you were. But if you aren't
then change it to <allow users=""> and put in the user names you allow.
Also the Web.config file this goes in should be in the root directory of
your web app and the paths in the <location> tags should be relative to your
root directory. Good luck! Ken.
 
Back
Top