Skip to content

IsUserInRole

Sheikh parvaz

Sheikh parvaz

Asked Oct 13, 2012, 4:24 AM EDTSolved
Share
LinkedInX

protected

void SetDestinationUrl(object sender, EventArgs e)

{

TextBox txtBox = (TextBox)LoginUser.FindControl("UserName"); if (Roles.IsUserInRole(txtBox.Text, "Guest"))

{

Response.Redirect(

"UserIndex.aspx");

if (Roles.IsUserInRole(txtBox.Text, "Administrator"))

{

Response.Redirect(

"AdminIndex.aspx");

}

}



The above code is showing me error by saying "The type or namespace anme IsUserInRole does not exist....."

Kindly help me out of it..

5 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Sandeep Singh Shekhawat
    ✓ Accepted answer0
    C#
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Security;
    
    
    namespace Supportticketsystem.Account
    {
        public partial class Login : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
            }
            protected void SetDestinationUrl(object sender, EventArgs e)
            {
                TextBox txtBox = (TextBox)LoginUser.FindControl("UserName");
                if (Roles.IsUserInRole(txtBox.Text, "Guest"))
                {
                    Response.Redirect("UserIndex.aspx");
    
    
                    if (Roles.IsUserInRole(txtBox.Text, "Administrator"))
                    {
                        Response.Redirect("AdminIndex.aspx");
                     }
                }
            }
        }
    }



    Its running successful on my system please chaeck inherits attribute on .aspx page under page directive.

    Inherits="Supportticketsystem.Account.Login"
    0
  • Sandeep Singh Shekhawat
    0
    Are you using namespace


    using System.Web.Security;
    0
  • Sheikh parvaz
    0
    Yes I am using this namespace still the problem persists?
    0
  • Sheikh parvaz
    0

    using



    System;


    using



    System.Collections.Generic;


    using



    System.Linq;


    using



    System.Web;


    using



    System.Web.UI;


    using



    System.Web.UI.WebControls;


    using



    System.Web.Security;



    namespace



    Supportticketsystem.Account


    {


       


    public partial class Login : System.Web.UI.Page


        {


           


    protected void Page_Load(object sender, EventArgs e)


            {



            }



           


    protected void SetDestinationUrl(object sender, EventArgs e)


            {


               


    TextBox txtBox = (TextBox)LoginUser.FindControl("UserName"); if (Roles.IsUserInRole(txtBox.Text, "Guest"))


                {


                    Response.Redirect(


    "UserIndex.aspx");



                   


    if (Roles.IsUserInRole(txtBox.Text, "Administrator"))


                    {


                        Response.Redirect(


    "AdminIndex.aspx");


                    }



                }



            }



        }


    }


    This is the whole program.

    0
  • Sheikh parvaz
    0
    IsUserInRole this still showing problem. problem is not with logic it with above method...
    0