rlb*_*usa 7 asp.net url filepath
有没有办法从ASP.NET的URL获取物理文件路径?
Scenerio:我有一个应用程序在两个服务器上,但它现在将更多,每个服务器将它放在一个不同的物理文件路径.现在我这样做:
//for server 1
if (Request.Url.GetLeftPart(UriPartial.Path).Contains(".com"))
 { Application["StoreFilesPath"] = "E:\\Data\\rootsite\\f1\\appsite\\Upload\\"; }
//for server 2
if (Request.Url.GetLeftPart(UriPartial.Path).Contains(".net"))
 { Application["StoreFilesPath"] = "E:\\Web\\rootsite2\\f34\\abc\\ghi\\appsite\\Upload\\"; }
但我需要做的是这样的事情:
//for all servers
Application["StoreFilesPath"] = getPhysicalFilePath() +"\\Upload\\";
我该怎么做?
您可以使用HttpServerUtility.MapPath,以获得一个文件的物理路径在服务器端,然后返回它在Application或Session对象,类似于你现在在做什么.
至于URL的物理路径 - 可能没有,因为URL可以重写.
| 归档时间: | 
 | 
| 查看次数: | 22226 次 | 
| 最近记录: |