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 8538177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:05:08+00:00 2026-06-11T11:05:08+00:00

I have created a base controller that each of my controllers inherit. In this

  • 0

I have created a base controller that each of my controllers inherit. In this controller I have the OnActionExecuting method. I use this to check the url for some parameters. The problem I have is that I get an exception whenever I post html data. I have setup the model using the [AllowHTML] tag and it works on all the other actions.

How do I make the OnActionExecuting method pay attention to the model validation?

This is what I have in my base controller

public abstract class BaseController : Controller
{
    [ValidateInput(false)]
    protected override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if ((Request.Params["api"] == null || string.IsNullOrEmpty(Request.Params["api"])))
            return;

        if ((Request.Params["api"] != null && !string.IsNullOrEmpty(Request.Params["api"])))
        {
            if (Session["api"] == null)
            {
                Session["api"] = Request.Params["api"];
            }
        }
    }

and below is an extract from my model

[MetadataType(typeof (MessagingMetaData))]
public partial class Message
{

}

public class MessagingMetaData
{
    [Required]
    [Display(Name = "Message")]
    [DataType(DataType.Html)]
    [AllowHtml]
    public string Body { get; set; }
}

here is the stack trace

[System.Web.HttpRequestValidationException]

Exception Message: A potentially dangerous Request.Form value was detected from the client (Content="

sdafdsafdsafdsac__DisplayClass12.b__d(String value, String key) at     Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyEvaluatedNameObjectEntry.ValidateObject() at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyEvaluatedNameObjectEntry.GetValidatedObject() at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazilyValidatingArrayList.get_Item(Int32 index) at System.Collections.Specialized.NameObjectCollectionBase.BaseGetKey(Int32 index) at System.Collections.Specialized.NameValueCollection.GetKey(Int32 index) at System.Collections.Specialized.NameValueCollection.Add(NameValueCollection c) at System.Web.HttpRequest.FillInParamsCollection() at System.Web.HttpRequest.GetParams() at System.Web.HttpRequest.get_Params() at System.Web.HttpRequestWrapper.get_Params() at ProjectX.BaseController.OnActionExecuting(ActionExecutingContext filterContext) at System.Web.Mvc.Controller.System.Web.Mvc.IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.b__14() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.ExecuteCore() at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.b__5() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.b__0() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.b__7(IAsyncResult _) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag) at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.b__d() at System.Web.Mvc.SecurityUtil.b__0(Action f) at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

sorry for the layout would not copy new lines for some reason

  • 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-11T11:05:09+00:00Added an answer on June 11, 2026 at 11:05 am

    Not sure if this is the solution to the problem, but is a work around that works.

    By changing Request.Params to Request.QueryString I guess the validation is not called

    public abstract class BaseController : Controller
    {
    [ValidateInput(false)]
    protected override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if ((Request.QueryString["api"] == null || string.IsNullOrEmpty(Request.QueryString["api"])))
            return;
    
        if ((Request.QueryString["api"] != null && !string.IsNullOrEmpty(Request.QueryString["api"])))
        {
            if (Session["api"] == null)
            {
                Session["api"] = Request.Params["api"];
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a gem that adds a new method to the class ActiveRecord::Base.
I have created a data base that comes in an installer that runs as
I have created some JQuery that will expand a div 'popup' on hover and
I have an abstract base Controller class and all action controllers are derived from
i have searched a lot. I'm facing this error Create method in Controller is
I have controller with action new , and I want it to create ActiveRecord::Base
I have created an app targeted for ios 4.1 with base SDK ios 5.0
I have introduced boost to our code base, on my machine I created a
So in my base template, I have: {% render EcsCrmBundle:Module:checkClock %} Then I created
I want to have one model & view that is served by multiple controllers

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.