简体   繁体   English

应用相对路径到ASP.NET中的物理路径

[英]App Relative path to physical path in ASP.NET

I simply try to convert "~/Telerik.Web.UI.WebResource.axd?imgid=310aa01d42ba47e1af090c60b520dd8e&type=rbi" this path to physical path. 我只是尝试将"~/Telerik.Web.UI.WebResource.axd?imgid=310aa01d42ba47e1af090c60b520dd8e&type=rbi"为物理路径。

I simply tried below code but it throws Exception and says "Illegal characters in path". 我只是尝试了下面的代码,但是它引发了异常并说“路径中的非法字符”。

Server.MapPath("~/Telerik.Web.UI.WebResource.axd?imgid=310aa01d42ba47e1af090c60b520dd8e&type=rbi") 

I am not exactly sure it is possible to do that or not. 我不确定是否可以这样做。

Edit: I actualy have RadBinaryImage That holds the url. 编辑:我实际上有RadBinaryImage持有的网址。 I want to have byte array from RadBinaryImage and this is what i try to access file. 我想从RadBinaryImage中获取字节数组,这是我尝试访问文件的内容。

尝试

Server.MapPath("~/Telerik.Web.UI.WebResource.axd") + "?imgid=310aa01d42ba47e1af090c60b520dd8e&type=rbi)"

How about [control].ResolveUrl instead? 怎么样[control].ResolveUrl呢?

MapMath is looking for a file, which & is not accepted in a file path. MapMath正在寻找文件,文件路径中不接受& You're just looking to get the "absolute URL" (or at least one that's folder agnostic) that the client can use. 您只是想获得客户端可以使用的“绝对URL”(或至少一个与文件夹无关的URL)。

Telerik.Web.UI.WebResource.axd is not physical resource, so it hasn't an equivalent on disk. Telerik.Web.UI.WebResource.axd不是物理资源,因此在磁盘上没有等效资源。 Probably is loaded/readed from a dll by its corresponding handler. 可能是由其相应的处理程序从dll加载/读取的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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