Display images outside app dir

crippa

Newcomer
Joined
Aug 4, 2003
Messages
3
Hi

It seems that displaying images with an <img>-tag outside the ASP.NET application directory is not allowed. ex: <img src="../../../../images/gif.gif">
The folder with the images can be anywhere on the server.

I guess that i can change the securety setings for ither IIS or the .NET framework but i dont realy want that.

How do I solve this in a simpla and(?) flexible way?

Thanks!
/Christer
 
You can display images located at any URL within an ASP.NET page. I'd check your relative path to make sure it is in fact correct. Also keep in mind that ASP.NET handles relative paths differently than straight HTML in some cases.
 
The path is ok.

So you can link an image that's located for example in c:\images when the application dir is C:\Inetpub\wwwroot\mywebapp by using the tag <img src="../../../images">?

/Christer
 
crippa said:
The path is ok.

So you can link an image that's located for example in c:\images when the application dir is C:\Inetpub\wwwroot\mywebapp by using the tag <img src="../../../images">?

/Christer

ASP.NET uses a windows account, named ASP_USER or something like that. if you want to access c:\somethingelse, you have to set folder permissions so that ASP.NET actually has access to the folder. by default, ASP_USER only has access to c:\inetpub

but it's not a very good idea to do that. try to keep your web applications all in the same place ... or set your application virtual directory to c:\somethingelse
 
crippa said:
The path is ok.

So you can link an image that's located for example in c:\images when the application dir is C:\Inetpub\wwwroot\mywebapp by using the tag <img src="../../../images">?

/Christer
No, you cannot do that unless you reconfigure that directory as the home directory, move it to the Web root or define it as a virtual directory. Otherwise, IIS has no access to that folder.
 
Last edited:
Making the directory outside c:\inetpub a virtual directory might be the solution!
I'll try that!

Thanks!
/Christer
 
If it is a permissions issue you can setup the aspnet process to run not under ASPNET user but impersonate a Win abuser. You set this up in you web.config file. This is a way to give the process more privileges without opening the door to the whole directory for every user that might hit your site.
 
Back
Top