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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:51:07+00:00 2026-06-09T21:51:07+00:00

I have tried so many combinations, but cannot get the validation to turn off

  • 0

I have tried so many combinations, but cannot get the validation to turn off on this code block

[ValidateInput(false)]
    public ActionResult aSavePageCopy()
    {
        aLoggedIn();
        int id = Convert.ToInt32(Request.Form["id"]);
        PagesDataContext pdc = new PagesDataContext();
        Page p = pdc.Pages.Single(row => row.ID == id);

        p.PageCopy = Request.Form["PageCopy"];

        pdc.SubmitChanges();

        return Redirect("/Admin/aViewPages");
    }

It seems that this works for others so I don’t see what I’m missing here. The error I get is A potentially dangerous Request.Form value was detected from the client

  • 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-09T21:51:08+00:00Added an answer on June 9, 2026 at 9:51 pm

    You could use FormCollection which is safe to access instead of Request.Form (but please don’t use it, see below for the real solution to your problem):

    [ValidateInput(false)]
    public ActionResult aSavePageCopy(FormCollection fc)
    {
        aLoggedIn();
        int id = Convert.ToInt32(fc["id"]);
        PagesDataContext pdc = new PagesDataContext();
        Page p = pdc.Pages.Single(row => row.ID == id);
    
        p.PageCopy = fc["PageCopy"];
    
        pdc.SubmitChanges();
    
        return Redirect("/Admin/aViewPages");
    }
    

    Of course that’s an absolutely ridiculous and lousy way to solve the problem. The correct way to do it is to use a view model (of course):

    public class MyViewModel
    {
        public int Id { get; set; }
        public string PageCopy { get; set; }
    }
    

    and then:

    [ValidateInput(false)]
    public ActionResult aSavePageCopy(MyViewModel model)
    {
        aLoggedIn();
        PagesDataContext pdc = new PagesDataContext();
        Page p = pdc.Pages.Single(row => row.ID == model.Id);
    
        p.PageCopy = model.PageCopy;
    
        pdc.SubmitChanges();
    
        return Redirect("/Admin/aViewPages");
    }
    

    or if you are using ASP.NET MVC 3 and wanted to disable validation only for a single property on your view model instead of doing it for the entire request you could decorate this view model property with the [AllowHtml] attribute:

    public class MyViewModel
    {
        public int Id { get; set; }
        [AllowHtml]
        public string PageCopy { get; set; }
    }
    

    and then you no longer need the [ValidateInput(false)] attribute on your action:

    public ActionResult aSavePageCopy(MyViewModel model)
    {
        aLoggedIn();
        PagesDataContext pdc = new PagesDataContext();
        Page p = pdc.Pages.Single(row => row.ID == model.Id);
    
        p.PageCopy = model.PageCopy;
    
        pdc.SubmitChanges();
    
        return Redirect("/Admin/aViewPages");
    }
    

    Not only that we have solved the problem but as you can see you no longer need to write any plumbing code in your controller action parsing around integers and stuff which is the role of the model binder.

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

Sidebar

Related Questions

This should be really simple, but I have tried many solutions posted on the
I have tried so many things, cannot figure this out, I am using this
I tried many ways to solve this problem but none works. suppose I have
I have tried many combinations and a few different PHP functions, but I still
Very frustrating one... I have tried many combinations of ', and so on but
Please help me figure this out. I've tried so many combinations but nothing seems
I have tried many different combinations of code using the eval command. However my
I have tried many permutations but they all don't seems to work well. Am
Hello friends I have tried many times but I am not successful than please
I want to get the page rank for any website. I have tried many

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.