We have an IHttpHandler for style sheets and add the <link/> to the page as follows:
HtmlGenericControl link = new HtmlGenericControl("link"); link.Attributes.Add("rel", "stylesheet"); link.Attributes.Add("href", "stylesheet.axd?d=" + HttpServerUtility.UrlTokenEncode(token)); head.Controls.Add(link);
In the stylesheet.axd handler, we UrlTokenDecode the query string parameter d as follows:
var token = HttpServerUtility.UrlTokenDecode(Request.QueryString["d"]);
This works most of the time, but from time to time we find one of the following two exceptions in our journal:
[FormatException: Invalid character in a Base-64 string.] System.Convert.FromBase64CharArray(Char[] inArray, Int32 offset, Int32 length) System.Web.HttpServerUtility.UrlTokenDecode(String input) ... [FormatException: Invalid length for a Base-64 char array.] System.Convert.FromBase64CharArray(Char[] inArray, Int32 offset, Int32 length) System.Web.HttpServerUtility.UrlTokenDecode(String input) System.Web.HttpServerUtilityWrapper.UrlTokenDecode(String input) ...
Any ideas what might cause this phenomenon?
Notes:
- the resulting URL is <1500, so below any known URL limits (e.g. IE: 2083).
- seems to be independent of the user agent (we have these exceptions for IE6,7,8, FF and Chrome)
- our (unconfirmed) suspicions include AntiVirus products, HTTP proxies, browser add-ons
- found this question related to remoteness, but it concerns a problem with presentation in a view
Josef Pfleger Sep 08 '09 at 9:31 2009-09-08 09:31
source share