Does anybody know what is the usefulness of the SPHttpUtility.NoEncode method? It seems like it takes a string as parameters and returns it without any modification.

Is there a case where you can use this and I'm missing it?

3 Answers 3


Looks like this function here just to have a stub for future use. Or probably vice versa, there was functionality some time agou, but after some refactoring it became obsolete :) I can also see 2 more overloads for it with (object) and (object, TextWriter) signatures. I would recommend to avoid these functions, they looks really strange.

  • I'm trying to understand the code for the BDC service aplications management pages in an effort to create a custom service application with the full features that you find on the OOTB. I saw this method used in some places. So I was wondering why would you write such code? :-) The stubs for future use seems to be a posibility. Commented Apr 12, 2011 at 19:01

The main reason for having that method is to force a developer on the SharePoint team that each string rendered to the client should be encoded. Or at least, the developer must have thought about whether the string should be encoded or not. Just returning the string does not put this knowledge in the code, however, having the developer call SPUtility.NoEncode makes it quite clear that the developer actually thought about the issue and decided that not-encoding the string is the best option.


Edit: You were the one who asked in SO? :-)

From Stackoverflow

The data in sharepoint that is markup content has to be encoded so that it can be passed around in xml without it breaking.

for example <a /> instead of "< a/ >" (without the spaces)

Therefore if you want to ouput the rendered instead of >a /< you use the NoEncode function to convert it to valid xml.

Hope that makes sense.

  • Can't see XML handling here ;) public static string NoEncode(string valueToEncode) { return valueToEncode; } Commented Apr 12, 2011 at 15:33
  • Shoban I know that this is what the documentation says this method does but when testing it doesn't do anything. :) Commented Apr 12, 2011 at 19:04
  • Strange! I did some testing too. I will do some more tests today and let me see if I find anything.
    – Shoban
    Commented Apr 13, 2011 at 4:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.