Jarmo:I tried Page.Header.InnerHtml += "something" again. I have many tags inside of head (master page). When I removed all entries, then it worked.
You are right! I tried to add a tag to the head tag and it gave me the exception you mentioned.
I'm not sure, but I think this is a bug.
I tried to render the contents of the header and i was able to get the rendered html:
StringBuilder sb = new StringBuilder();
System.IO.StringWriter tw = new System.IO.StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(tw);
this.Header.RenderControl(hw);
string headerRenderedHtml = sb.ToString();
Response.Write(Server.HtmlEncode(headerRenderedHtml));
no exceptions and the html was rendered..
isn't it strange? i googled around looking for something with no luck. anyways, since your solution works fine then there's nothing to worry about. thanks for sharing it by the way.