- 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")

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
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?
smithmrkAuthor Commented:
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"
            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
smithmrkAuthor Commented:
OK, so here is an is telling me NO the file does not exists, but the image displays on the screen for the ImageURL.

NO - \\\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.

OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Kyle AbrahamsSenior .Net DeveloperCommented:
and if you try to open \\\D$\PayeeValidation_Images\2000135_1F.png in explorer from the server the file opens?

What's the  System.Configuration.ConfigurationManager.AppSettings("PayeeValidation_ImagePath") value?
smithmrkAuthor Commented:
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.

Kyle AbrahamsSenior .Net DeveloperCommented:
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.
smithmrkAuthor Commented:
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 \\\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()

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

Kyle AbrahamsSenior .Net DeveloperCommented:
That would be a permission issue.  By impersonating you're using the context of the impersonated user to access the file.

There's also a difference between viewing something in a virtual directory / share and accessing the file itself.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smithmrkAuthor Commented:
Thanks for your help!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.