Hi, i need a little help here, in my app i've created 3 users by ASP Web Site Administration Tool and i want each user to be redirected to different pages from the login.aspx.

i.e. username1 enters his username and pw, press the login button, he should be redirected to page1.aspx.

username2 enters his username and pw, press the login button, should be redirected to page2.aspx ... and so on, so basically the page to be displayed to the user should depend on the Username.

What happens is when any of them tries to login, he's redirected to the default.aspx page, how can i manage to do this?.

Thanks.

Dani AI

Generated

A quick summary and a few practical options to make per-user landing pages maintainable.

found the simple fix: send each authenticated user to a different page after login. That works for a handful of accounts. and suggested per-username redirects and storing a path in a data store. Those approaches are fine for small projects, but a couple of patterns below scale and avoid fragile, hard-coded logic.

Example: role-based routing (recommended when users share responsibilities)

protected void Login1_LoggedIn(object sender, EventArgs e)
{
    string user = Login1.UserName;

    if (System.Web.Security.Roles.IsUserInRole(user, "Admin"))
        Server.Transfer("~/Admin/Dashboard.aspx");
    else if (System.Web.Security.Roles.IsUserInRole(user, "Member"))
        Server.Transfer("~/Member/Home.aspx");
    else
        Server.Transfer("~/Public/Welcome.aspx");
}

If per-user landing pages are required, store a validated landing URL in the user profile or a lookup table and consult it at login. Always whitelist and normalize stored paths before navigating. Example pattern:

string landing = (string)Profile["LandingPage"]; // or query DB
if (!string.IsNullOrEmpty(landing) && IsAllowedPath(landing))
    Server.Transfer(landing);
else
    Server.Transfer("~/Default.aspx");

Notes and pitfalls

  • If using the built-in Login control, handle the LoggedIn event (it already creates the auth cookie) rather than re-authenticating.
  • Clear the control's DestinationPageUrl if you are controlling navigation in code, otherwise it can interfere.
  • Validate any stored path against a whitelist to prevent open-redirects.
  • Choose Server.Transfer when you want to avoid an extra round-trip and keep the original URL; choose a client redirect when you want the browser URL to change.

These patterns keep routing logic centralized, make it easier to add users, and improve security compared with scattered per-user if/else chains.

Anyone !!

Solved, Response.Redirect("~/Page.aspx");

In Username1
Response.redirect(page1.aspx)
In Username2
Response.redirect(page2.aspx)
In Username3
Response.redirect(page3.aspx)

Hellooooo buddy
you can take a string and give the path of page in database
with the help of insert query and when the user enter his user id aur password then fetch the path of that page in sql server

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.