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?
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?
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.
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.