3

In my asp.net website I create user with their details, If suppose the surname of the user is Sam's then when I edit the user the display in the text box is Sam's but in database it is stored as Sam's, and When I just try to update name as Sam's then i get the error below, How should I show the name in the text box txt_EditLastName.Text = gvrow.Cells[2].Text;

A potentially dangerous Request.Form value was detected from the client (ctl00$MainContent$txt_EditLastName="Sam's").
1
  • Is this ASP.net MVC? It doesn't really look like it. Commented Nov 15, 2011 at 16:27

2 Answers 2

3

I got this error because Visual Studio 2010 added a little bit of security. To work around it you need to add ValidateRequest="false" to the page directive or add <pages validateRequest="false" /> in the web.config file. I put it in the wrong spot at first, so make sure you put that in the <system.web> area of your web.config file.

This link will help. http://www.cryer.co.uk/brian/mswinswdev/ms_vbnet_server_error_potentially_dangerous.htm

Sign up to request clarification or add additional context in comments.

3 Comments

+1: Good answer, but to guard yourself you should explain that the above approach does sacrifice some security.
Yes, you are right. With my site, it didn't matter because it is only people in my company that are using the pages with less security. If @John is ok with his site being a little less secure, then this is a really easy fix.
But I dont want the text box to display Sam&#39;s it has to display as Sam's
1

I used a find and replace of ' with `

' - Apostrophe
` - Grave Accent

The Grave accent looks the same and can be stored in SQL databases without messing them up. The grave accent is usually found above the Tab button on your keyboard, to the left of the numbers.

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.