Note: instead of attempting to answer existing questions I chose a topic that would hopefully standout and save other developers time in resolving this issue quickly
View required code changes in the message thread (pinned in this forum) http://forums.asp.net/891513/ShowPost.aspx. This thread shows how to modify the CSK to run under ASP.NET 2.0. I recently updated it for the issue "Images not appearing" (mapping issue) - SOLUTION #2. This solution should work under ASP.NET 1.1 as well as ASP.NET 2.0.
My complements to the chef on the amazing design of the CSK - I've learned a great deal on the power of ASP.NET while attempting to resolve this issue; an issue that seems to be an age old issue - not because of any inferior design of the software (it is actually superior) but because of the ISP's inability to properly setup the environment for it to run.
The above code changes are an
ISP/IIS INDEPENDENT FIX.
We are no longer victim to their inability (or unwillingness) to setup the IIS environment for use with the CSK.
For those interested, let me share what I learned which will provide some insight into why the few lines of code fix this issue.
------
The magic starts in the following lines of code in the web.config file:
<
httpHandlers>
<add verb="*" path="*.jpg" type="ASPNET.StarterKit.Communities.ImageHandler"/>
<add verb="*" path="*.jpeg" type="ASPNET.StarterKit.Communities.ImageHandler"/>
<add verb="*" path="*.gif" type="ASPNET.StarterKit.Communities.ImageHandler"/>
</httpHandlers>
The above lines of code tells ASP.NET to use the ImageHandler class to process any files that end with .
jpg, .
jpeg, or .
gif. The ImageHandler application basically queries the SQL Server for the image and displays it.
So why do some images display and others don't? First let me note that all of the images would display if they existed in the specfied path; the images that display actually exist at the specified location. The problem is that most of the images exist only in directories that are dynamically generated (they do not physically exist on the server) so if the
ImageHandler class is never run to retrieve and display the images - the images won't display.
So why doesn't the ImageHandler run? This is the fault of the ISP for one of 2 reasons:
1. They do not want to configure IIS to
associate the above mentioned files with ASP.NET. It is within this association that the power lies. For example - if you double click on a document on your hard drive the operating system will find the program that is
associated with it and automatically launch it so that you can view your document. If there is no association, you will not be able to view the document (database, spreadsheet, image, etc) until you create one - same thing with the images. If there is no association with ASP.NET then the above Web.config file entries will mean nothing to the system and the ImageHandler will never run to load the images.
2. They do not correctly associate the file because they do not understand the concept - perhaps they did what they where asked to do (I've been here - done this) but because the developer didn't understand what they were asking for; when the ISP complied with the change it didn't work. Without getting technical - if you send them the instructions to associate the images with ASP.NET, without telling them that the files won't actually exist, they they will not know to disable the "default" option of "Ensure files exists". The results are that the ImageHandler will run however because the full pathname does not exist IIS will not permit the image to display.
So two very important things have to happen for the CSK to display the dynamically generated images. First, IIS has to have the images associated with the image file types. Second, the default operation of "ensure file exists" has to be disabled. If you are fortunate enough to have had these two things done then you will be one of the "many" people who can successfully run the CSK without incident. If you do not have these two things done you will be one of the "many" victims who are powerless to resolve the issue because you do not have access to the IIS configuration.
So why does your fix allow the images to be viewed? Studying Redd's solution actually provided the answer - I simply modified the manner in which the solution operates. The problem was to figure out how to use his solution to honor the intent of the CSK design - to be able to have the ImageHandler class handle images without additional coding (thus the <httpHandlers> entry in web.config).
The solution started with first finding an ASP.NET extension that would, by default, be configured to process images that would not exist - and then insert a wedge to run the ImageHandler code - I was glad to see that .ASPX fit the need. Glad because I knew where the entry point was for the ASPX extension - it was in the CommunitiesModule.cs class in the Application_BeginRequest() method.
The rest was history! All I had to do was ensure my image ended with an ASPX (Redd's design) and I would be guaranteed to be in the Application_BegineRequest() method. All that remained was to ensure all image files ended with an extension of
.img.aspx, i.e., MyLogo.jpg
.img.aspx (to distinguish my image files from actual aspx files).
The cool part was that I was able to rename all the applicable images dynamically by just modifying two files -
Logo.cs and
ImageUtility.cs (a testimony to the great design of this application). All I did was insert code that appended an
.img.aspx to the existing image names (at the source) and now these images when referenced would kick in the ImageHandler class!
I hope this helps, if not, please ask so that we can clarify for the benefit of future developers. I trust the helplessness that a developer feels when they have no control over the output has forced many to look elsewhere - if we can keep developers here (and get them back) then the CSK community will benefit.