Link to home
Start Free TrialLog in
Avatar of smithmrk
smithmrkFlag for United States of America

asked on

ASP.net - IIS Virtual Directory

Hello Experts!
I have a Virtual Directory setup in my IIS under my Web Site that points to another server that has my images.  I can not seem to figure out how to get my Web Site to see this Virtual Directory to pull the images.

Please see attached Screen Shots.

ImageFile = Server.MapPath("~/PayeeValidation_Images")

Thanks,
Mark
ErrorMessage.jpg
IIS-Setup.jpg
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

It might be a permissions issue.  Are you using anonymous access or windows authentication?  Does the application pool user (the identity running the app pool) have permissions for the share?
Avatar of smithmrk

ASKER

No permission issues...It can't see the file?
This is what I'm doing to see if it can see the file:

        If File.Exists(Server.MapPath("~/PayeeValidation_Images/" & ImageFileName.Trim)) = True Then
            lbl_Client.Text = "YES"
        Else
            lbl_Client.Text = "NO"
        End If

It keeps coming up as NO...however this works:
for ImageURL...but I need to OPEN the Image First:

DocumentImage.ImageUrl = System.Configuration.ConfigurationManager.AppSettings("PayeeValidation_ImagePath") & "/" & ImageFileName.Trim
OK, so here is an example...it is telling me NO the file does not exists, but the image displays on the screen for the ImageURL.

NO - \\10.1.115.27\D$\PayeeValidation_Images\2000135_1F.png

I need to open the image file first before I display it on the screen to get the Image Height and Width.

Mark
and if you try to open \\10.1.115.27\D$\PayeeValidation_Images\2000135_1F.png in explorer from the server the file opens?

What's the  System.Configuration.ConfigurationManager.AppSettings("PayeeValidation_ImagePath") value?
Yes, I can open those files from my Mapped Drive L:\PayeeValidation_Images

The AppSetting is just the name of the folder = "PayeeValidation_Images"...that's all.
In case the folder name should ever change I could just change it in the WebConfig.

Mark
Try putting another entry for the physical path . . . use your L: instead of the mapped path.

The mapped drive may be accessing a share or something rather then the hidden (D$) drive.
OK, maybe I have something setup wrong in the IIS?

I have a mapped drive L:\ that I can see the images from.
I also have it setup in IIS as \\10.1.115.27\D$\PayeeValidation_Images...because it would not let me select the L:\ Mapped Drive from IIS.

I logged in and can see the images from IIS when I click on the Virtual Directory and when I use the command I showed you above I can display the Image using the URL however I need to be able to Open the Image so I can get the Height and Width, this is where I can not figure out why it can even see the images?

I just tried this and now I'm getting Logon Failure BUT it still displays my image?
Dim DirInfo As New DirectoryInfo(Server.MapPath("~/PayeeValidation_Images/"))
Dim DirFiles As FileInfo() = DirInfo.GetFiles()

Mark
I found this...
Which seems to work when adding that line to my Web.Config File:

http://www.codingdefined.com/2014/08/using-unc-path-for-storing-and.html

Mark
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help!

Mark