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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:33:13+00:00 2026-06-17T23:33:13+00:00

I am member of team with 25 developer.we use mvc.net application that security is

  • 0

I am member of team with 25 developer.we use mvc.net application that security is a n important for us.we use @Html.AntiForgeryToken() and anything that related with security but We are concerned about Prevent XSS hacking.
we encode every where but some places we need html from user.
What is the best practice for Prevent XSS hacking?

  • 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-17T23:33:14+00:00Added an answer on June 17, 2026 at 11:33 pm

    The golden rule to prevent XSS is to HTML encode everything that you are outputting to a view.

    Hopefully the @ Razor function already does that automatically for you.

    So when you write one of the following you are pretty safe:

    @Model.SomeProperty
    @Html.DisplayFor(x => x.SomeProperty)
    

    You should be careful with the @Html.Raw helper:

    @Html.Raw(Model.SomeProperty)
    

    If you use that the output will not be HTML encoded. This doesn’t mean that your site is vulnerable to XSS injection. For example if you have total control of the property and is not coming from an user input you should be pretty safe.

    If you are using the WebForms view engine then you should be more careful because the <%= function doesn’t HTML encode the output.

    So the following is not safe:

    <%= Model.SomeProperty %>
    

    You should use one of the following:

    <%= Html.DisplayFor(x => x.SomeProperty) %>
    <%: Model.SomeProperty %>
    

    If on the other hand you need to output some user input without HTML encoding it I would recommend you using the AntiXSS library from Microsoft. It will filter out all dangerous tags from the input and you are safe to output it. For example it will remove the <script> tags from the input. There’s also an article on MSDN about this library that you might checkout.

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

Sidebar

Related Questions

I'm a member in a team that develop a Delphi application. The memory requirements
I'm a member of a team with more than 20 developers. Each developer works
im working with a large team, and im making functions that return html code,
I'm developing an application that makes heavy use of web services. I will be
I work on a small web team where I am the only .NET developer
Is it possible to add team members to an individual developer account? The documentation
I am going to develop my first application (4 members team).I am not aware
I'm member of development team, and the team admin sends me a distribution certificate
A number of team members update a central ASP.NET dev Website project, not a
This question assumes there's a blessed central repository that members of a team clone

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.