简体   繁体   中英

Serving up a file not located within the IIS's virtual directory

I have an MVC web site, and I have no problems serving up image files that are located within my virtual directory. I am able to access my files as such http://localhost/images/1.jpg

How can I serve up files if they are located in another drive? For eg, if they are located in D:\\images\\1.jpg .

Without knowing what you are trying to achieve, let me start by saying that this is not advised. The web application is supposed to work inside a sandbox when it comes to IO access of the host environment. However things can change if you are in a shared hosting environment.

What's preventing you from copying these images to a subfolder within your virtual directory?

Another option is to create a separate virtual directory for this outside folder and access it just as another resource in the web.

Again, you might get better response if you describe what you are trying to do in a bit more detail.

I agree with @Uchitha, from an architectural perspective, I would not try this. If you really have too, because of circumstances out of your control, perhaps take a look at Symbolic Link Paths. More details at the following msdn article: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363878(v=vs.85).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM