sqlVirtualFile ported to windows 2008/ IIS7 breaking...

Discussion in 'Windows / IIS' started by bcsmith, May 14, 2009.

  1. I had implemented a solution making files available using the SQLVirtualDirectory,
    SQLVirtualFile, and SQLVirtualPathProvider several years ago..using asp.net 2.0 windows 2003 and IIS 5? (on discountasp.net).

    Now I find that I need a similar solution so I was trying to import this section of the old solution into a new application using windows server 2008 / IIS 7 and asp.net 3.5.

    I got the application working perfectly on my local machine using Visual Studios 2008. However when I put the application on discountasp.net a problem occurs in that the virtual File system always fails the check in my implementation of SQLVirtualPathProvider class in the IsVirtualFile...in here there is a check to see if the file is virtual or not based on a comparision to a specified string...if the file starts with the specified string then the file should be assumed to be virtual and retrieved from SQL.

    Here is the code in question:

    String sReportPath = Globals.Settings.File.FileDirectoryBase;
    System.Globalization.CultureInfo cultInfo = new System.Globalization.CultureInfo("es-ES", false);
    int a1 = String.Compare(virtualPath, 0, sReportPath, 0, 11, true, cultInfo);
    bool retVal = (a1 == 0);


    The thing that I am confused by is what would be different about the new environment that would cause this to fail on the discountasp.net server (i.e. windows server 2008 / iis 7) but not in visual studios 2008?

    To try to figure this out I took the old application (the part dealing with SQLVirtualFile) and put it back to discountasp.net .....This code worked under server 2003 and I made no changes to it (other than emanating the part of the website not being used...) and this application had the same problem as my new port.....

    I had suspected that this would happen and it confirms that it is most likely NOT the code, but something in the environment change that is causing the problem....

    I have no idea what would cause a string.compare to fail this has me really confused.

    Any suggestions?

    I am also looking for suggestions on better ways to locate problems on the discountasp.net server....right now I am going to extremes of putting out debug writes to try to find what the problem is...since it ONLY happens on the discountasp.net server.... does anyone have suggestions on how to run diagnostics on code located on the windows 2008 discountasp.net IIS server?

    Thanks.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    What error are your getting?
     
  3. string.comparision fails

    I am not getting an "Error" in the classic sense which has made the problem hard to locate. What is happening is that when I try to access the file using the IsVirtualFile check....the check is failing and the code looks for the file as a "real" file instead of a virtual file that can be found only in SQL Server.....

    So in my case the I am trying to do a hyperlink on the file and instead of seeing the file as a virtual file and pulling it from SQL the code is treating it like a normal file and trying to link based on an invalid address.

    In the new code I am using a marker of /wcjc/Files as indicator tag that the file is a virtual file...in the original code I used /puse/reports. What normally happens is that the string compare checks for files starting with the marker. If it is true then the file is consider to be virtual and it routes the file access to SQL server instead of the normal file access.....

    But both the original code and the new code now fail the string.compare that I included in the first post....and the file is considered to be a "real" file....Since I can't run debugging on the code on the discountasp.net server I don't know exactly what is going on...and I want to be careful in what I say as I may be wrong....but all indicators seem to point to the string.compare as being the problem....failing this check would create what I am seeing...I can't think of any other code path that would cause this result....but I am working on assumptions as I can't reproduce the error when running the code locally on Visual Studios 2008.

    I am aware that there are alot of differences between server 2003/IIS 6 and server 2008/IIS 7.....but I don't know enough about this area to even begin to figure out what could account for this problem.

    Any suggestions on a possible solution or even a way to diagnois this problem would be a great help. Thank.
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    I would try throw an exception with all these variables

    virtualPath,sReportPath,cultInfo

    and compare the values with what the values are when you run it on localhost.
     

Share This Page