Displaying local htm file in iframe?

橙三吉。 提交于 2020-01-02 09:54:17

问题


I am saving some emails on my local machine using MailBee.NET Objects in htm format. A separate folder is created for each email using email messageID on server for example

D:\Emails\GmailId1380ec660e0e656a\doc.htm

is an email downloaded from gmail. I am saving also the above mentioned path in database so I can use it later. Now I am trying to display this htm file in an iframe but it is not working. A user clicks on email which takes him to the read_email page on which I am trying to assign the path mentioned above to an iframe but the iframe remains blank.

emailMessage.Attributes.Add("src",commandReader["email_message_path"].ToString());

emailMessage is the name of iframe and commandReader is normal SqlDataReader which I am using to read the path of the file mentioned above and then assigning that path to src attribute of iframe, I have placed this code in page_load event.

But as I said Iframe remains blank. Please help me out.

Thanks.


回答1:


Local files are referenced with the file URI scheme. If your email message path is only D:\Emails\... then you'll have to prepend it with file:// :

file://D:\Emails\...

Note that most browser will prevent you from including a local file from a remote website !.




回答2:


Have you tried putting file:/// before the path to the file? Like file:///D:\Emails\GmailId1380ec660e0e656a\doc.htm



来源:https://stackoverflow.com/questions/11152103/displaying-local-htm-file-in-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!