Tuesday, November 22, 2005

No images allowed in the app_data folder

I had my first opportunity today to try to create a web site with Visual Studio 2005. I made it about two steps before running into a brick wall. The concept of Master Pages seems like a really cool one, but I'm not sure how to make it work together with CSS and maybe two or three user controls. So I tried to set up a master page; no problem; tried to associate default.aspx with it; problem. The property is grayed out. A little research told me that the field could be filled in through code in the @page declaration, so I tried adding that with trepidation. I was pretty sure that the field was grayed out for a reason, and sure enough, that didn't get me what I was looking for.

I quickly found out that "Content" pages are the only kind of page that can be associated with master pages, but all the intuitions I've built up about finding things don't apply to 2005. For example, I tried to "Add New Item" to the solution, expecting to find "Content Page" as an option. No dice. I tried looking through the toolbox for something I could drag onto the page to make it a content page; nothing. So I did quite a bit of additional research and poking around on the web, and in Dev Studio, and in the Dev Studio help. But it took me quite a long time to actually find the solution, which I did by trial-and-error: right-click in the content placeholder in the master page and choose "Add Content Page". I'm sure I could have found help on this...somewhere.

This was directly followed by problem #2; I simply tried to add an image to my page. Copy-and-pasting from VS 2003 on my system failed, to my mild surprise, but then I noticed this nice "App_Data" folder in the project, and it was clear that any images or sounds needed to go here. Right-click on it, add new item, and drag the picture to my page, no problem!

Except that when I hit F5, no image is to be seen. Back to the web. This time, there's a fundamental problem: I can't figure out any terms to search for that describe my problem with any hope of clustering to the right solution. I tried "visual studio app_data image doesn't show up", "asp.net image failing", "Visual Studio 2005 images", "visual studio 2005 add jpg to web page", but all these terms give me much too generic results back. If the solution to my problem was in one of those result sets, it must have been on page 37 at least.

Finally, I went to the Microsoft forums, and specifically to forums.asp.net . Here, a search for app_data turned up dozens of results, and I tried to narrow it down by searching for "app_data debugging", which was what I was trying to do. Bingo! By sheer luck it turned out that the problem involves permissions and running inside the debugger, but the fact of the matter is that the app_data folder is not supposed to hold images at all, only databases.

I added a separate folder for the images and everything worked fine. Whew. What adventures await me in Visual Studio tomorrow?

Icerocket tags



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.