CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

Getting my head around HTTPheader and HTMLheader. But no favicon yet.

Thanks to the great feedback on my last post on Response.AppendHeader I'm beginning to see some light. I was indeed naive Response.AppendHeader appends a HTTP header to the response. A HTTP header indicates things like downloadable files. I was trying to manipulate an HTML header which steer the layout of the HTML rendered by the browser.

The HTML returned to the browser can be manipulated in every detail by using the Response.Filter property. Page Brooks pointed to a nice article on completely customizing the HTML header. Which has its price and does not solve everything.

The pages in my application need two links:

  • A link to a stylesheet. This link does not have to be in the head of the page to work. As Codebetter buddy Ben pointed out you can also put this in an user control. My app has a menubar used on all pages, the stylesheet is now dynamically set in the text of a literal control there. Which resembles my very first try at the problem (where I created literals on the fly in the init of the basepage) but without any dirty hacks. That's solved and clear.
  • A link to an icon. But even when this link is hard coded in the header of an aspx the icon does not show up. According to the HTML editor of VS (2003 and 2005) the "Shortcut Icon" value for the REL attribute is unknown. The icon shows on the default.aspx main page because it is in the root and has the default FavIcon.ico name. But as it looks now asp.net is blank on it.

As the last post had such great feedback I'm not giving up yet. Does anybody know the way to set an icon from code ?


Published Oct 31 2005, 04:16 PM by pvanooijen
Filed under:

Comments

Daniel F said:

No idea if this'll help or not, but to get IE to show the icon up, you have to bookmark the page. Painful.
# October 31, 2005 8:50 PM

pvanooijen said:

No that's not it. IE will show the icon in the addressbar when it's in the HTMLhead. It adds the icon to the favorites.

To make life even more complicated: FF does also show the icon in the addressbar when the link is in the body.
But it does not show up in the bookmarks....

# November 1, 2005 4:06 AM

Leo said:

Actually - you CANT set a favicon from code; it's a client thing. When bookmarking, IE / FF looks if it can find /favicon.gif und uses it, if present. You could write a HTTPHandler which handels requests to that file, and do your work there (eg return a differetn image ect...)
# November 2, 2005 4:08 AM

Peter's Gekko said:

A web page in in VS 2005 is assembled from several source files. Two of them are visible in VS: the markup...
# November 2, 2005 4:15 AM

Peter's Gekko said:

A web page in in VS 2005 is assembled from several source files. Two of them are visible in VS: the markup...
# November 2, 2005 10:38 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!