如何访问其他位置比asp.net的wwwroot [英] How to access the location other than wwwroot in asp.net

查看:207
本文介绍了如何访问其他位置比asp.net的wwwroot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以访问使用使用Server.Mappath 服务器的物理位置。这给了我这是的wwwroot 文件夹内的物理路径。

I can access the physical location of a server using Server.MapPath. This gives me the physical path that is inside of wwwroot folder.

我要一些数据保存到同一个服务器说 D的另一驱动器:驱动器。我想,我不能得到的物理位置 D:使用驱动器使用Server.Mappath ,因为它是外的wwwroot 文件夹中。所以我会很难codeD这个位置到我的项目。但现在的问题是,我想用服务器的URL,比如 www.mysite.com/image/myimage.png 来访问保存的数据
其中,图像/ myimage.png 位于 D:驱动器。所以,我只是想知道的是它可以或不可以使用asp.net或请建议我应该怎么做才能解决这个问题。

I want to Save some data into the other drive of the same server say D: drive. I think I can't get the physical location of D: drive using Server.MapPath because it is outside of the wwwroot folder. So I will hardcoded this location into my project. But now the problem is I want to access the saved data using server url like www.mysite.com/image/myimage.png where image/myimage.png located in D: drive. So I just want to know is it possible or not using asp.net or please suggest what should i do to overcome this problem

推荐答案

好吧,有两件事情:


  • 不要硬code您的位置,在你的web.config使用AppSettings的,那他们就是在那里:<一href=\"http://msdn.microsoft.com/en-us/library/610xe886%28v=vs.100%29.aspx\">http://msdn.microsoft.com/en-us/library/610xe886%28v=vs.100%29.aspx

您想从另一个驱动器提供图片。您需要在IIS中设置一个虚拟目录下你的网站来实现: http://support.microsoft.com/kb/172138

You want to serve images from another drive. You need to set up a virtual directory in IIS under your website to achieve this: http://support.microsoft.com/kb/172138

这篇关于如何访问其他位置比asp.net的wwwroot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆