一个.aspx页面怎样才能得到它的文件系统路径? [英] how can an .ASPX page get its file system path?

查看:112
本文介绍了一个.aspx页面怎样才能得到它的文件系统路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面something.aspx,关联codebehind something.aspx.cs。在codebehind,我想知道something.aspx的文件系统位置。有什么便捷的方法得到它?

I have a page something.aspx, with associated codebehind something.aspx.cs. In that codebehind, I want to know the filesystem location of something.aspx. Is there any convenient way to get it?

更新:我得到了一些优秀的答案,不幸的是没有的,因为别的东西疯狂的我做的工作。我对编码我通过在URL中一些额外的信息,所以它看起来是这样的:

Update: I got several excellent answers, which unfortunately didn't work because of something else crazy I'm doing. I'm encoding some additional information on the URL I pass in, so it looks like this:

HTTP://server/path/something.aspx/info1/info2/ info3.xml

此行的服务器处理(我没有使用查询字符串参数来解决其他一些code,我没写)。但是,当我打电话使用Server.Mappath(Request.Url.ToString())我得到一个错误,与'信息'段完整的URL不是有效的虚拟路径。

The server deals with this OK (and I'm not using querystring parameters to work around some other code that I didn't write). But when I call Server.MapPath(Request.Url.ToString()) I get an error that the full URL with the 'info' segments isn't a valid virtual path.

推荐答案

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.htt$p$pquest.physicalpath.aspx\">Request.PhysicalPath

这篇关于一个.aspx页面怎样才能得到它的文件系统路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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