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

  • SEARCH
  • Home
  • 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 6058233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:34:38+00:00 2026-05-23T08:34:38+00:00

In my custom model binder I use bindingContext.ValueProvider.GetValue(propertyName); I do have [ValidateInput(false)] on the

  • 0

In my custom model binder I use

bindingContext.ValueProvider.GetValue(propertyName);

I do have [ValidateInput(false)] on the action. However the GetValue call above results in

A potentially dangerous Request.QueryString value was detected from the client

How do I make my custom model binder get the unvalidated value from the value provider? Of course when it finds that there’s ValidateInput(false) on the action.

  • 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-05-23T08:34:39+00:00Added an answer on May 23, 2026 at 8:34 am

    Just in case someone is curious, here’s a quick solution. Just call CheckUnvalidated() in BindModel/BindProperty methods. This will replace default QueryStringValueProvider with the unvalidated version.

      MethodInfo GetActionMethod(ControllerContext controllerContext)
      {
         var action = controllerContext.RouteData.Values["action"] as string;
         return controllerContext.Controller.GetType().GetMethods().FirstOrDefault(x => x.Name == action ||
            x.GetCustomAttribute<ActionNameAttribute>().SafeGet(a => a.Name) == action);
      }
    
      void CheckUnvalidated(ControllerContext controllerContext, ModelBindingContext bindingContext)
      {
         var method = GetActionMethod(controllerContext);
         if (method == null)
            return;
         if (method.GetCustomAttribute<ValidateInputAttribute>().SafeGet(x => x.EnableValidation, true))
            return;
         var collection = bindingContext.ValueProvider as ValueProviderCollection;
         if (collection == null)
            return;
         var old = collection.OfType<QueryStringValueProvider>().FirstOrDefault();
         if (old != null)
            collection.Remove(old);
         collection.Add(new UnvalidatedQueryStringValueProvider(controllerContext));
      }
    
      class UnvalidatedQueryStringValueProvider : NameValueCollectionValueProvider
      {
         public UnvalidatedQueryStringValueProvider(ControllerContext controllerContext)
            : base(controllerContext.HttpContext.Request.Unvalidated().QueryString, CultureInfo.InvariantCulture)
         {
             }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom model binder with public override object BindModel(controllerContext, bindingContext) that checks
I have written a custom model binder for List in my MVC project however
This is my custom model binder. I have my breakpoint set at BindModel but
In my application I have a custom model binder that I set to the
I use custom model binder to bind Order/OrderItem in my actions. This model binder
I have created a custom Model Binder that inherits from DefaultModelBinder, and overriding the
I'm using the MVC 2 RC. I have a custom model binder that used
I have a custom model binder that takes a comma separated list and cleans
I'm using ASP.NET MVC 3 and have my custom model binder. public class NewsModelBinder
I have a custom model binder inheriting from DefaultModelBinder. What I want it to

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.