Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:42:41+00:00 2026-06-03T23:42:41+00:00

Im using class name RightCheckerAttribute to check user permission in MVC3 application… So the

  • 0

Im using class name RightCheckerAttribute to check user permission in MVC3 application…
So the RightCheckerAttribute class is like this…

    public bool isAdmin { get; set; }

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        HttpContextBase context = filterContext.HttpContext;

        bool result = Convert.ToBoolean(context.Request.QueryString["isAdmin"].ToString());

        if (isAdmin != result) 
        {
            RouteValueDictionary redirecttargetDictionary = new RouteValueDictionary();
            redirecttargetDictionary.Add("action", "NoPermission");
            redirecttargetDictionary.Add("controller","Singer");
            filterContext.Result = new RedirectToRouteResult(redirecttargetDictionary);

        }

        //base.OnActionExecuting(filterContext);
    }

So in Method i applying this have head as..

[RightChecker (isAdmin=true)]

Im Executing this method as this..

http://localhost:5576/Singer/DeleteSinger?isAdmin=true

The problem is whether I’m passing true or false… I got result variable as false… And I’m getting:

Exception[Null Object references]…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:42:42+00:00Added an answer on June 3, 2026 at 11:42 pm

    It seems you are not passing the isAdmin=false or isAdmin=true in your query string. It works for me. However you will need to handle the situation where you are not passing the querystring parameter. Check my implementation. As mentioned in the comments section of the question, it is not secured enough to pass this through a query string.

            public class RightChecker : ActionFilterAttribute
            {
                public bool IsAdmin;            
    
                public override void OnActionExecuting(ActionExecutingContext filterContext)
                {
    
                   bool result = false;
                   if (filterContext.HttpContext.Request.QueryString["isAdmin"] != null)
                   {
                           bool.TryParse(filterContext.HttpContext.Request.QueryString["isAdmin"].ToString(), out result);
                   }
    
                   if (IsAdmin != result) 
                   {
                       //your implementation
                   }
                }
            }
    

    Your action method

        [RightChecker(IsAdmin=true)]
        public ActionResult AttCheck()
        {
            return View();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function like this... I am trying to insert a class name
How do I get the class name/type using the class name string? like Dictionary<string,
Using class name I am firing a click event in jquery. Class names are
I want to get the class name using jQuery And if it has an
I'm looking for a way using jquery/javascript to get a class name when I
i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();
I am using: class ISearchFuncs : public Osp::Ui::IActionEventListener , public Osp::Ui::ITextEventListener , public Osp::Ui::IScrollPanelEventListener
I would like to expand the functionality of some class using class_eval. I would
I want Element by using class name Now I am using GWT 2.0 Please
I'm trying to group related elements using class name. They, in turn, are all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.