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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:02:04+00:00 2026-05-27T11:02:04+00:00

I am writing an MVC3 site, which uses tinymce as a WYSIWYG text editor.

  • 0

I am writing an MVC3 site, which uses tinymce as a WYSIWYG text editor. I save that text via an AJAX call using jQuery. I’ve found the query is not sent, if my data includes HTML, so I need to do this:

 var postData = {
                  couponId: couponId,
                  coupon: escape(coupon),
                  imagePath: image,
                  imageAlignment: imageAlignment
                };

             $.post('@(Url.Action("SaveCoupon"))', postData, function (data) {

in order to get my data passed through to the server. This turns

<p>this is a test</p>

in to

%3Cp%3Ethis%20is%20a%20test%3C/p%3E

I’ve been trying to work out how to convert it back. The HtmlString, HtmlHelper and HttpUtility classes just return it verbatim, I thought HttpUtility.HtmlDecode was what I needed for sure, but it just plain does not do what I need. I need to store this as decoded HTML in my database, so I can’t just re-encode it on the client side ( although I am concerned that I won’t be able to send it back using AJAX either, I’ve not even got that far, yet ). What’s the best way to transmit HTML through an AJAX call, store it in the form it was entered, and return it back to the client for display ?

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

    I’ve found the query is not sent, if my data includes HTML

    No, you found wrong. The query is sent but the server rejects it because it contains dangerous characters. Basically it throws an exception before it reaches your controller action. In ASP.NET MVC 3 there are a couple of possibilities to avoid this.

    The first one is to decorate your view model property that will receive the HTML with the [AllowHtml] attribute (recommended):

    public class CouponViewModel
    {
        public int CouponId { get; set; }
        [AllowHtml]
        public string Coupon { get; set; }
        public string ImagePath { get; set; }
        public string ImageAlignementh { get; set; }
    }
    

    which is what your controller action will take as parameter:

    [HttpPost]
    public ActionResult SaveCoupon(CouponViewModel model)
    {
        ...
    }
    

    Now when sending your AJAX request don’t do any escaping or stuff. jQuery will take care of properly url encoding your parameters:

    var postData = {
        couponId: couponId,
        coupon: coupon,
        imagePath: image,
        imageAlignment: imageAlignment
    };
    
    $.post('@Url.Action("SaveCoupon")', postData, function (data) {
        ...
    });
    

    Another possibility is to decorate the entire action with the [ValidateInput] attribute which will disable request verification for the entire request (not recommended):

    [HttpPost]
    [ValidateInput(false)]
    public ActionResult SaveCoupon(CouponViewModel model)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an MVC3 site, and I'm using JQuery unobtrusive validation to validate my
I'm writing a site in MVC3, using Entity (linked to Postgres, but not sure
I am writing a MVC3 project. Right now I have a table which has
I am writing a MVC3 project. Right now I have a table which has
I am using Mvc3 and my view engine is razor and also writing jquery
I have an MVC3 site and I am writing code to register a user.
I have a .net mvc3 site and want to use the ActiveMq amq.js ajax
I'm writing an MVC3 application that will need to make use of URL rewriting
I am writing a fairly simple MVC3 application that allows a user to retrieve
I'm writing an ASP.net MVC3 application using Entity Framework Code First and SqlCe4. I

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.