Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

We have one .NET application deployed in IIS 7. In certain text boxes if we enter special charaters like < > or &, it is converted to html code as > < and & while saving to database.

But we have the same code in diff server and it is working fine.

What can be the solution.

Should we use html encoder and decoder Or is there any IIS setting needs to be changed.

Thanks
Posted
Comments
ZurdoDev 20-Jun-14 7:27am    
It gets converted because someone wrote some code to do it. What exactly is the question?
Ranjeet Patel 20-Jun-14 7:58am    
I think you should verify that the same code is written on the other servers too. because it happens only because of code. you should use to sent the <, > in a string by @Html.Raw if you are using MVC.net of if you are using asp.net then find the alternatives Thanks,

1 solution

As Ranjeet said it has happened somewhere in your code , but by using the HttpUtility you can decode it. here is an example :


XML
HttpUtility.HtmlEncode("< > &"); //result &lt; &gt; &amp;
        HttpUtility.HtmlDecode("&lt; &gt; &amp;"); //result < > &
 
Share this answer
 
Comments
sucharita dutta 23-Jun-14 21:34pm    
Thanks Jafarine,

This change needs to be done for all the text boxes, is there any settings what can be change in one place for the entire application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900