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

  • Home
  • SEARCH
  • 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 8952371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:51:32+00:00 2026-06-15T13:51:32+00:00

I am inserting html in database for the first time so I need some

  • 0

I am inserting html in database for the first time so I need some advice am I making it right and safe.
I have class with property:

[AllowHtml] public property Description {get;set}

In View I have a tinyMCE (on text area) where user input his data.
When I display that html later I use:

@Html.Raw(Model.Description)

I don’t know should I do something else to prevent some attack on site.
I have tried to input:

<script>alert('attack');</script>

but nothing happens it saves it in database and display as a normal text later.
Also I wonder if user leave some tag unclosed can he break my layout somehow.
What are smart steps when dealing with scenario like this?

  • 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-15T13:51:33+00:00Added an answer on June 15, 2026 at 1:51 pm

    What should happen is that the html should be encoded before it is written to the database. If you look in your database you should see something like this (or at least if things are safe you should):

    &lt;script&gt;alert(&#39;attack&#39;);&lt;/script&gt;
    

    Now when this is written to the page by html raw, it appear on screen as it did when it was submitted, but if you inspect the page you will still see the same thing.

    ASP.Net actually makes it very difficult to write code that opens your site up to abuse, so you should generally be fine. It is worth doing some more reading around the topic though as it’s good stuff to be aware of especially if mentoring others.

    Some links:

    Preventing Javascript and XSS attacks

    http://msdn.microsoft.com/en-us/library/ff649310.aspx

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

Sidebar

Related Questions

After inserting new html to DOM,I need to add some listeners to it. But
I'm inserting some HTML into a MySQL database table. But when I get it
For some reason this just isn't inserting into my database... HTML <form name=testimonials_form method=post
I have this Code Where i am inserting some values in database. I am
I have a <select> drop down that I'm inserting into my HTML via jQuery.
I have written a application that parses the html code of some web pages.
I have two database tables, guestlist and attendance On one HTML page, I have
Basically I have an html form for inserting a product. The field names, as
I am inserting some values into a mysql database, and before I insert I
I have an extensive form inserting into a SQL database and then from an

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.