Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My class and I cant figure out how to get our login page to work. We need it take us to different pages, one for admin and one for a normal person based on the login ID. So if the ID matches the ID for an admin it will take it to a page for the admin, but a normal ID when a normal person makes their account it will take them to our welcome page. We're coding in C# on Visual Studio. Ill update this if we figure it out for anyone else asking this question. This what we got so far.

ASP.NET
 AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="CleanIA3.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>`your text`
    <form id="form1" runat="server">
        <div>
          
            <center>  <asp:Login ID="Login1" runat="server" DestinationPageUrl="~/success.aspx"></asp:Login></center>
        </div>
    </form>
</body>
</html>

Success page is the page that it takes a normal user to when they login, we are yet to figure out the admin part.

What I have tried:

We've tried DestinationPageURL and it didnt work.
Posted
Updated 7-Aug-23 22:06pm
v3

1 solution

Do it in the Server code: the C#, not HTML / Javascript.

User logs in, his username and password are passed to the server.
The server validates the username / password combination (using a salted and hashed password stored against the username in the DB) and if valid retrieves the user type at the same time from the same DB: Admin or Member.
If it's a member, you redirect him to the generic "success page", it's it's an admin, you redirect to an Admin menu: HttpResponse.Redirect Method (System.Web) | Microsoft Learn[^]
 
Share this answer
 
Comments
Member 16067018 8-Aug-23 5:49am    
so heres my C#, what should i do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CleanIA3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}
OriginalGriff 8-Aug-23 7:31am    
"heres my C#, what should i do?"

Write some code? You haven't done anything yet at all!
Member 16067018 8-Aug-23 11:02am    
ok yea i get it now lol, for some reason i thought that the HTML i wrote transferred into C# for some reason. But yea, ill start writing in C# from now on and get back to you. Even if you dont respond i very much appreciate the help you've given me. And i can definitely see why youre the top expert lol, you replied INSTANTLY!
OriginalGriff 8-Aug-23 11:23am    
Nope, normally the C# generates the HTML!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900