I am using login.aspx and I want to ridirect users to different URL after the login. Is this possible? I tried for a while but I can't find a way to do that.
user1 should have access to other data from a sql db than user2. In detail:
I have a db where two prices are in (article, price1, price2). When user1 is logged in he should only get Article and price1. If user 2 than only Article and price2.
I thought the best way to handle that is to have two pages with two different sql queries. I tried out to find a code where you can use a variable in the sql query (sqldatasource), but I did not find a way.
I would suggest using 1 query to get the article, the price1 and the price 2. Once you have this, you need to specify which price to use depending on the user.
chris_koehne
Member
8 Points
59 Posts
User Login redirect to differnet pages
Feb 26, 2007 03:31 PM|LINK
Hi,
I am using login.aspx and I want to ridirect users to different URL after the login. Is this possible? I tried for a while but I can't find a way to do that.
Thanks for your answers, Chris
LuisE
Member
313 Points
89 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 05:10 PM|LINK
After they have logged in and event is raised, which is the LoggedIn event.
<asp:Login ID="Login1" runat="server" OnLoggedIn="Login1_LoggedIn">
</asp:Login>
protected void Login1_LoggedIn(object sender, EventArgs e)
{
Response.Redirect("NewPage.aspx");
}
chris_koehne
Member
8 Points
59 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 05:35 PM|LINK
LuisE,
thanks for your answer.
I have 2 users. "User1" I want to redirect to "~side1" and "user2" I want to redirect to "~side2".
I do not know how. Hope you can help me.
Thanks, Chris
LuisE
Member
313 Points
89 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 05:49 PM|LINK
chris_koehne
Member
8 Points
59 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 06:01 PM|LINK
LuisE,
user1 should have access to other data from a sql db than user2. In detail:
I have a db where two prices are in (article, price1, price2). When user1 is logged in he should only get Article and price1. If user 2 than only Article and price2.
I thought the best way to handle that is to have two pages with two different sql queries. I tried out to find a code where you can use a variable in the sql query (sqldatasource), but I did not find a way.
Perhaps you have an idea?
Thanks Chris
LuisE
Member
313 Points
89 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 06:18 PM|LINK
Chris,
I would suggest using 1 query to get the article, the price1 and the price 2. Once you have this, you need to specify which price to use depending on the user.
-Luis
chris_koehne
Member
8 Points
59 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 06:25 PM|LINK
Luis,
how can I specify the price to use? Can I use a variable in the sql query for the loggedin user?
Chris
LuisE
Member
313 Points
89 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 06:35 PM|LINK
Just use 1 query for example:
SELECT article, price1, price2 FROM Articles WHERE id = 2
This will return the 3 things, the article, price1 and price2.
So then depending on the User, for example:
if(User.HasDonated)
{
price = price1;
}
else
{
price = price2;
}
return price;
AjPtl
Participant
1345 Points
272 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 06:36 PM|LINK
Hey Chris
I would assign role to user and check the role, Depend on the roles give rights to access pages or application.
thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If this post answers your question please mark it as Answered.
chris_koehne
Member
8 Points
59 Posts
Re: User Login redirect to differnet pages
Feb 26, 2007 06:47 PM|LINK
Sorry, this is my code:
<%
@ Page Language="VB" %><!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
script runat="server"></
script><
html xmlns="http://www.w3.org/1999/xhtml" ><
head runat="server"> <title>Unbenannte Seite</title></
head><
body> <form id="form1" runat="server"> <div> <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" Width="375px"> <ItemTemplate>Artikelnummer:
<asp:Label ID="ArtikelnummerLabel" runat="server" Text='<%# Eval("Artikelnummer") %>'> </asp:Label><br />VK1:
<asp:Label ID="VK1Label" runat="server" Text='<%# Eval("VK1") %>'></asp:Label><br />VK2:
<asp:Label ID="VK2Label" runat="server" Text='<%# Eval("VK2") %>'></asp:Label><br /> <br /> </ItemTemplate> </asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>" SelectCommand="SELECT [Artikelnummer], [VK1], [VK2] FROM [Artikel]"></asp:SqlDataSource> </div> </form></
body></
html>If I try what you had written I just get an Parsererror. I understand what you mean, but I have no idea where to put the code that it will work.
Thanks, Chris