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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:03:47+00:00 2026-05-28T07:03:47+00:00

If I have a controller: [HttpPost] public ReturnType ControllerMethod(CustomModel c) { … } A

  • 0

If I have a controller:

[HttpPost]
public ReturnType ControllerMethod(CustomModel c)
{
...
}

A third party is posting data to this method:

abc-xyz=testdata

One way, would be to use:

Request.Params["abc-xyz"]

However, in the case where the Request could contain malicious code, if any Request Parameter contained some problematic code, IIS would throw an HttpRequestValidationException as soon as Request.Params[""] is called.

Now, rather than turn off that validation everywhere, I’d like to map the posted data to my model. That way, if the “potentially malicious code” is contained in any parameter that isn’t “abc-xyz”, my application won’t throw a HttpRequestValidationException. It will however, check the used paramaters, and throw a HttpRequestValidationException if the accessed data is potentially malicious.

How do I do that if the posted data has a dash/hyphen in the name?

I’ve tried a few variations including:

public class CustomModel
{
    [Required]
    public string abc_xyz
}
  • 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-28T07:03:47+00:00Added an answer on May 28, 2026 at 7:03 am

    You should write your own ModelBinder in this case that transforms the values from the request into the ones needed for CustomModel.

    To over come the request validation, you can turn it off with the ValidateInputAttribute on your controller action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a controller like this: [HttpPost] public JsonResult FindStuff(string query) { var
I have a controller with an action method as follows: public class InventoryController :
I have a controller with action: [HttpPost] public ActionResult Add(Question container, HttpPostedFileBase file) {
Suppose you have the following controller action [HttpPost] public ActionResult Save( CustomerModel model )
I have this url in my login page: http://localhost:5550/login?ReturnUrl=/forum/456 I have this controller: [HttpPost]
So I have this controller called Cars, and it has: namespace MySite.Controllers { public
Here is what I have: Controller [HttpPost] public ActionResult GetNumbers(int id) { List<int> privIDs
Here is my controller: [HttpPost] public ActionResult Index(HttpPostedFileBase excelFile) { /*Somewhere here, I have
In my MVC 3 application I have a very basic controller [HttpPost] public ActionResult
I have multiple controller actions that takes an id public ActionResult Get(int? id) {

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.