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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:46:02+00:00 2026-06-12T02:46:02+00:00

I have an ASP.NET MVC 4 project in which I use an HTML input

  • 0

I have an ASP.NET MVC 4 project in which I use an HTML input element in a View. The value of this element is sent to the server via a JQuery post call. I’m not using any Razor syntax, and I haven’t manually added any special code to the Controller action.

When I set one of the post parameters to HTML code, the call will fail, returning a 500 Internal Server Error. My question is, in order to help prevent XSS attacks, does JQuery terminate the call on the fly or is it ASP.NET MVC? Second, how would I turn off this feature?

  • 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-12T02:46:04+00:00Added an answer on June 12, 2026 at 2:46 am

    does JQuery terminate the call on the fly or is it ASP.NET MVC?

    None of them. It’s the ASP.NET engine. This feature was present in ASP.NET much before ASP.NET MVC even existed and since ASP.NET MVC is built on top of ASP.NET it inherited it.

    Second, how would I turn off this feature?

    By decorating the view model property you are binding to this value with the [AllowHtml] attribute:

    public class MyViewModel
    {
        [AllowHtml]
        public string Html { get; set; }
    }
    

    And now you could have the following controller action:

    [HttpPost]
    public ActionResult SomeAction(MyViewModel model)
    {
        ...
    }
    

    that you are invoking with jQuery.ajax and sending arbitrary HTML contents:

    $.ajax({
        url: '@Url.Action("SomeAction")',
        type: 'POST',
        data: { html: '<div>Hello World</div>' },
        success: function(result) {
    
        }
    });
    

    Obviously by doing this you fully acknowledge the fact that the user can send any arbitrary HTML, including scripts and all dangerous stuff to your site. So to prevent XSS attacks make sure that you have properly encoded this value before displaying it back in some page.

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

Sidebar

Related Questions

I have a master page in my asp.net MVC project, which has code like
I have a question I have a project asp.net mvc which is developed in
We have an ASP.Net MVC project that will start with a single web server
I have a ASP.NET MVC 4 project and a SQL View (vvItem). ItemController MVCAppEntities
I have asp.net mvc 4 web application project on my server in IIS Directory.
I'm on a asp.net MVC 2 project and have a view that inherits from
I have an ASP.NET MVC 2 project in which I've created a data transfer
I have an ASP.NET MVC 4 project which is to be deployed to Azure
I have a directory /media/fonts in my asp.net mvc project which contains fonts for
I'm making an Asp.Net MVC 3 project which should have about 10-15 views. How

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.