Bill Robertson's Blog

Atlas UpdatePanel with GetWebResourceUrl

I noticed there are two overloads for GetWebResourceUrl, one that allows htmlEncoding and one that defaults to htmlEncode = false.  Of course the only public method is the one that sets htmlEncode = false.  So when I put out a web resource in an atlas update panel it renders the link as:

<script src=”WebResource.axd?d=[value]&t=[value]></script>

This is not valid Xml because the & remains unencoded.  However all of the runtimes resource emissions use the internal GetWebResourceUrl method that DOES the html encoding

<script src=”WebResource.axd?d=[value]&amp;t=[value]></script>

The only way I have found to get a web resource url through an update panel is to use "hack" code.

string url = [x].GetWebResourceUrl( ... ).Replace( "&t=", "&amp;t=" )

which is clearly not good.  When I don't use the replace logic on it, the xml is invalid so the xml DOM is empty, therefore the altas client script blanks out the Panel's UI.

I'm currently exploring other workarounds.  I think I could get the internal GetWebResourceUrl method called up through reflection, but I shouldn't have to.  I've also posted this question on the asp.net forums.

Leave a Comment

(required) 

(required) 

(optional)

(required)