如何在asp.net webform中显示iframe中其他驱动器的pdf? [英] How to display pdf from other drives inside iframe in asp.net webform?

查看:106
本文介绍了如何在asp.net webform中显示iframe中其他驱动器的pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在应用程序中显示pdf tat并且它可以工作。但是我需要在其他驱动器外面显示pdf我该怎么做?

这是我的代码:

string path1 = Session [path1]。ToString() ;

string filepath = Server.MapPath(path1);

System.Web.UI.AttributeCollection aCol = iFrame1.Attributes;

aCol。添加(src,文件路径);

我从数据库获取路径,我也尝试了server.mappath和gor使用物理路径的错误

帮助我..

i tried displaying pdf tat is inside application ath and it works. But i need to display pdf outside from other drives how do i do it?
this is my code:
string path1 = Session["path1"].ToString();
string filepath = Server.MapPath(path1);
System.Web.UI.AttributeCollection aCol = iFrame1.Attributes;
aCol.Add("src", filepath);
where i get path from a database and i also tried server.mappath and gor error of using physical path
help me..

推荐答案

一切都取决于其他驱动器相对于客户端浏览器的位置。究竟是什么出现在HTML代码中。您可以在服务器上访问pdf这一事实并不意味着客户端也可以访问它 - 这涉及访问权限,协议,公开服务甚至内联网/外联网类问题。因此,如果您想确保您的客户端可以读取您所需的资源,以确保您的Web应用程序正在为其提供服务,即使它存储在其范围之外。



您的服务器端应该传输文件 - 不要依赖客户端来访问它。请看这里: http://weblogs.asp .net / dmiyamasu / archive / 2008/02/25 / save-server-memory-with-response-transmitfile.aspx [ ^ ]



更高级的观点: http://davidarodriguez.com/blog/2013/05/29/downloading-files-from- a-server-to-client-using-asp-net-when-file-size-too-big-for-memorystream-using-generic-handlers-ashx / [ ^ ]
Everything depends on where that outside from other drives lies relative to the client browser. What exactly does appear in the html code. The fact that you can reach the pdf on the server does not implies that the client can reach it too - and this involves access rights, protocols, exposed services and even intranet/extranet kind of questions. So if you want to be sure that your client can read the resource you need to ensure that your web application is serving it, even if it is stored outside it's scope.

Your server side should transmit the file - don't rely on the client to reach it. Look here: http://weblogs.asp.net/dmiyamasu/archive/2008/02/25/save-server-memory-with-response-transmitfile.aspx[^]

A more advanced view of this: http://davidarodriguez.com/blog/2013/05/29/downloading-files-from-a-server-to-client-using-asp-net-when-file-size-is-too-big-for-memorystream-using-generic-handlers-ashx/[^]


首先,如果这是一个Web应用程序,则不应该假设PDF可以在页面上呈现。 PDF不是W3标准的一部分;并非所有系统和浏览器都支持它,而那些支持通常是通过可能安装或不安装的插件来实现。 (例如,我不这样做是因为我对Adobe查看器的质量非常不满意,而且我的浏览器不支持在浏览器中查看,但我根本不会打扰我。)



现在,基本上,对于Web应用程序,没有驱动器。如果PDF文件位于服务器端,则所有可访问资源都应位于站点的根目录下。 Web应用程序在沙盒环境中执行,不允许访问任何其他内容。



如果PDF文件出于某种奇怪的原因,则在客户端,是的,可以有驱动器(而不是在所有系统上,只在某些系统上),但Web应用程序根本不知道任何关于它的信息,因此,即使文件可以呈现,也没有任何东西可以保证它。



所以,看起来你应该放弃这个想法和别的东西。如果您向我们解释您的最终目标,您可能有机会获得进一步的建议以及该怎么做。到目前为止,我们只能告诉你不该做什么。



-SA
First of all, if this is a Web application, you should not assume that PDF can be rendered on a page at all. PDF is not a part of W3 standards; not all systems and browsers support it, and those which support usually do it via plug-ins which may or may not be installed. (I, for example, don't do it because I'm very dissatisfied with the quality of Adobe viewer, and the viewer I have does not support viewing in browsers, but I does not disturb me at all.)

Now, essentially, for a Web application, there are no "drives". If the PDF file is on the server side, all accessible resources should be under the root directory of the site. A Web application is executed in a sandboxed environment which won't allow access to anything else.

If the PDF file is, by some weird reason, on the client side, yes, there can be "drives" (and not on all systems, only on some), but a Web application does not "know" anything about it at all, so, even though a file can be rendered, nothing can guarantee it.

So, it looks like you should simply abandon the idea and thing of something else. If you explain to us your ultimate goals, you may have a chance to get further advice and what to do. So far, we could only tell you what not to do.

—SA


这篇关于如何在asp.net webform中显示iframe中其他驱动器的pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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