The Microsoft Visual Studio .NET logo.Image via Wikipedia
I'm an ASP.Net programmer and I can admit, I don't know everything. In fact, since upgrading from Visual Studio 2003 to 2005, I really feel like I don't know a lot.

One of the major pluses to VS2005 was the use of Master Pages. But I came across a problem that was it not for the help of some seriously smart geeks on experts-exchange, I doubt I would have ever figured it out.

The application I was writing is using 2 masterpages.

The first one (Main.master) is parent for all of my pages except login.aspx & error pages, it contains a banner image (located \img\TitleBanner.gif) and an asp:menu control.

The second one (Misc.master) is the parent for the initial login.aspx page & any generic error pages that I am redirecting to. It is identical to the Main.master page, minus the asp:Menu control.

In Visual Studio, everything looks fine & all images are showing. However, upon debugging when the login.aspx page loads, the banner in the Misc.master is not showing (red X), however all contents of the contentplaceholder are fine.

When I log in successfully, it will redirect me to my Main.aspx which is a child of Main.master and the page looks fine, then if I log out (which redirects to the login.aspx) then, and only then does the banner image show correctly.

Initially, both Masterpages were pointing to the same banner image in \img\TitleBanner.gif but I've tried copying the image into the root of the project (outside of the img folder) but still no go.

The Answer!!

The Answer was given to me by someone named guru_sami and basically he lead me to figure out that since my web.config file was blocking all anonymous access that it was also blocking access to the images within my folder to show on the master page. So, the solution was to create a second web.config file within my \img folder giving allow all users access, which then allowed the images to be used in the master page!

These are just one of the coding things I wanted to share! Enjoy!

Reblog this post [with Zemanta]