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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:43:34+00:00 2026-05-29T07:43:34+00:00

In my Razor MVC application, I added the feature where a model property allows

  • 0

In my Razor MVC application, I added the feature where a model property allows HTML by doing:

[AllowHtml]
public string Body { get; set; }

This works great. But I was wondering, I want to make sure the user doesn’t submit malicious data, so has anyone built a utility or library to filter out bad HTML data like JavaScript statements, etc? I do plan on decoding the HTML and displaying in the UI, so naturally I would like to be somewhat restrictive. I understand I have to do this manually from code, just curious for some pointers or utilities.

Thanks.

  • 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-29T07:43:35+00:00Added an answer on May 29, 2026 at 7:43 am

    Absolutely! The anti-xss library from Microsoft has a sanitizer:
    It’s simple to use and I cover this (and a lot more) in the “Hack Proofing your ASP.Net Applications” video series going live on pluralsight.com this week. Theres more than just html encoding if you use html, theres caution for dangling html problems used for cross site scripting as well as improper use of javascript functions that can lead to xss as well. Check out the video series (the topic is a lot longer than a post here to cover)

    
    Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment(yourHtml);
    
    

    Get the code in the web protection library. Note in asp.net 4.5 this should be included in System.Web.Security

    http://wpl.codeplex.com/

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

Sidebar

Related Questions

I have an EF model in a .NET 4.0 MVC Razor application. I'm pulling
I am working on asp.net MVC 3 application. I have created a Razor view
I've got a running MVC 3 (Razor) application with Forms authentication. I can easily
i am working in asp.net mvc 3 web application which uses razor code. and
I have created a Razor view in my asp.net MVC 3 application. It is
I have a problem in my application I am using MVC 3 with razor
I am writing an application in asp.NET, I use the MVC 3 model(views engine
I have a MVC 3.0 .Net 4.0 Razor application that is periodically giving me
I have a MVC 3 application with Razor. The form is data driven and
Working on an ASP.NET MVC 3 (Razor) application, that's mainly concerned with UGC (user

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.