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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:25:23+00:00 2026-05-27T10:25:23+00:00

My model contains a string field called longdescription which gets the value of the

  • 0

My model contains a string field called “longdescription” which gets the value of the tinymce editor’s content

Public class ArticleModel:BaseModel{
            [StringLength(8000, ErrorMessage = "Long description must be in 8000 characters or less"), AllowHtml]
    public string LongDescription { get; set; }
}

Here is my controller code

[HttpPost]
public ActionResult AddEdit(ArticleModel model)
{
    string buttonName = Request.Form["Button"];
    if (buttonName == "Cancel")
        return RedirectToAction("Index");

    // something failed
    if (!ModelState.IsValid)
    {

     }

    // Update the articles
  }

My problem is when I use Request.Form to access the post value, it’s working fine without throwing “A potentially dangerous….” error, but when I use Request.Params[“Button”], it threw that errors. Is something I am missing?

Thanks

Updated

Sorry the answer Adam gave doesn’t really answer my question. Can anyone give more suggestion?

  • 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-27T10:25:24+00:00Added an answer on May 27, 2026 at 10:25 am

    It is the HttpRequest.Params getter that is throwing this exception. This getter basically builds and returns a key/value pair collection which is the aggregation of the QueryString, Form, Cookies and ServerVariables collections in that order. Now what is important is that when you use this getter it will always perform request validation and this no matter whether you used the [AllowHtml] attribute on some model property or if you decorated the controller action with the [ValidateInput(false)] attribute and disabled all input validation.

    So this is not really a bug in the AllowHtml attribute. It is how the Params property is designed.

    As @Adam mentioned in his answer you should avoid accessing request values manually. You should use value providers which take into account things such as disabled request validation for some fields.

    So simply add another property to your view model:

    public class ArticleModel: BaseModel
    {
        [StringLength(8000, ErrorMessage = "Long description must be in 8000 characters or less")]
        [AllowHtml]
        public string LongDescription { get; set; }
    
        public string Button { get; set; }
    }
    

    and then in your controller action:

    [HttpPost]
    public ActionResult AddEdit(ArticleModel model)
    {
        string buttonName = model.Button;
        if (buttonName == "Cancel")
        {
            return RedirectToAction("Index");
        }
    
        // something failed
        if (!ModelState.IsValid)
        {
    
        }
    
        // Update the articles
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Model called statistics which has a value field that contains Goals
I've a String field on my model that contains an html value, my problem
I have an active record Song model with a songhash field (string(255)) that contains
If a django model contains a foreign key field, and if that field is
My application works with the MVC model. The model contains a Bindable class (BindableItemsClass)
I have a model that contains a foreign key value, then in the form
I have a Django app with a model that contains a field of type
I have json with field that contains two different types. fields:[{value:ZIELONE OKO},{value:{@nil:true}}] I have
If the model class does not contain a creation_time field, is it possible to
The scenario Suppose I have the following two model classes: public class ProductColor {

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.