Displaying local htm file in iframe?

2019-05-20 05:48发布

问题:

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