Proposed Answer prob with role base login

  • 26 Maret 2012 18:20
     
     

    I have create site to learn.

    there are 3 folder

    1.user it contains user page.

    2.tech it contain tech page.

    3.admin it contain admin page.

    and one folder for login controals.

    also created Role user,tech and admin. for corresponding folder.

    Role:

    admin: can go to tech and user page.

    user: can only see his page.

    and

    tech: can only see his page.

    and writen code in loggingIn event of login control.

    which is

     protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
        {
            if (User.IsInRole("tech"))
            {
                Login1.DestinationPageUrl = "~/tech/tech.aspx";

            }
            else if (User.IsInRole("admin"))
            {
                Login1.DestinationPageUrl = "~/admin/admin.aspx";
            }
            else if (User.IsInRole("user"))
            {
                Login1.DestinationPageUrl = "~/user/user.aspx";
            }
           

        }

    but when i click login button each time i get different result.

    I don't understand what is going on.

    • Dipindahkan oleh Lie You 02 April 2012 2:52 ASP.Net related. (From:Visual C# General)
    •  

Semua Balasan

  • 26 Maret 2012 21:24
     
     Saran Jawaban
    That looks like the User role has changed or the IsInRole method is faulty. But there's nothing more that can be guessed at given the code shown.

    Regards David R
    ---------------------------------------------------------------
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
    Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.

    • Disarankan sebagai Jawaban oleh Lie You 29 Maret 2012 2:05
    •  
  • 01 Juni 2012 1:49
    Moderator
     
     
    The correct forum for this question is http://forums.asp.net/

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID: Microsoft Transcript