problem in redirecting pages based on Roll in asp.net

Discussion in 'C#' started by sbglobal79, Aug 3, 2009.

  1. #1
    Dear DP user !

    I am developing asp.net application with c# . I used there role provider .
    I assigned three role : 1. admin 2 . free user 3. paid user

    now i want to redirect page after logged in according to role .i have used following code .:


    protected void Login2_LoggedIn1(object sender, EventArgs e)
    {


    if (Roles.IsUserInRole(User.Identity.Name, "Administrator"))
    {
    Server.Transfer("admin/default.aspx");


    }
    else if (Roles.IsUserInRole(User.Identity.Name, "free mambership"))
    {
    Server.Transfer("user/welcome.aspx");
    }


    but it not redirecting admin panel when i login as administrator.

    So guide us ...
     
    sbglobal79, Aug 3, 2009 IP
  2. jamieellis

    jamieellis Active Member

    Messages:
    427
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Try Response.Redirect(<Your pages here>); instead.
     
    jamieellis, Aug 3, 2009 IP
  3. sbglobal79

    sbglobal79 Banned

    Messages:
    724
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Dear jamieellis !

    I have already tested by using response.redirect . But same problem here ...
     
    sbglobal79, Aug 4, 2009 IP
  4. ziv

    ziv Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ziv, Aug 4, 2009 IP
  5. sbglobal79

    sbglobal79 Banned

    Messages:
    724
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    55
    #5
    yes , this is done all ready.but when i try to visit admin page , its redirect login page , And after login by using administrator roll , i can visit my admin control panel.
     
    sbglobal79, Aug 4, 2009 IP
  6. sbglobal79

    sbglobal79 Banned

    Messages:
    724
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    55
    #6
    I am developing asp.net application with c# . I used there role provider .
    I assigned three role : 1. admin 2 . free user 3. paid user

    now i want to redirect page after logged in according to role .i have used following code .:


    protected void Login2_LoggedIn1(object sender, EventArgs e)
    {


    if (Roles.IsUserInRole(User.Identity.Name, "Administrator"))
    {
    Server.Transfer("admin/default.aspx");


    }
    else if (Roles.IsUserInRole(User.Identity.Name, "free mambership"))
    {
    Server.Transfer("user/welcome.aspx");
    }


    but it not redirecting admin panel when i login as administrator.

    So guide us ...
     
    sbglobal79, Aug 6, 2009 IP
  7. sbglobal79

    sbglobal79 Banned

    Messages:
    724
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    55
    #7

    is there no expert about roll base authentication ?
     
    sbglobal79, Aug 12, 2009 IP
  8. akanus

    akanus Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    First : set web.config file in admin folder. yourhost/admin/ :

    
    <?xml version="1.0"?>
    <configuration>
        <appSettings/>
        <connectionStrings/>
        <system.web>
    		<authorization>
    			<allow roles="admin" />
    			<deny users="*" />
    		</authorization>
        </system.web>
    </configuration>
    
    Code (markup):
    second set the code :
    Server.Transfer("~/admin/default.aspx");
    Code (markup):
     
    akanus, Aug 13, 2009 IP
  9. sbglobal79

    sbglobal79 Banned

    Messages:
    724
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    55
    #9
    I have done already both thing that u told me . But facing same problem. Any way , Thanks for reply.
     
    sbglobal79, Aug 14, 2009 IP