Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何预览html文件而不保存它?_C#_Asp.net_Html_Browser - Fatal编程技术网

C# 如何预览html文件而不保存它?

C# 如何预览html文件而不保存它?,c#,asp.net,html,browser,C#,Asp.net,Html,Browser,Hy 在我的应用程序中,我将字符串存储为html文件的内容 如何在浏览器中预览此内容(假设它是从原始内容修改的),但不必将其保存在本地 更新 预览将显示在另一个选项卡或窗口中。您可以创建一个预览页面,只将html字符串写入响应,如下所示: protected void Page_Load(object sender, EventArgs e) { string htmlString = //initialise the string here Re

Hy

在我的应用程序中,我将字符串存储为html文件的内容

如何在浏览器中预览此内容(假设它是从原始内容修改的),但不必将其保存在本地

更新


预览将显示在另一个选项卡或窗口中。

您可以创建一个预览页面,只将html字符串写入响应,如下所示:

    protected void Page_Load(object sender, EventArgs e)
    {
        string htmlString = //initialise the string here
        Response.Write(htmlString);
        Response.End();
    }

您可以创建一个预览页面,只将html字符串写入响应,如下所示:

    protected void Page_Load(object sender, EventArgs e)
    {
        string htmlString = //initialise the string here
        Response.Write(htmlString);
        Response.End();
    }

使用控件
System.Windows.Forms.WebBrowser
,您可以使用
DocumentText

例如:

webBrowser1.DocumentText = "<HTML><BODY style=\" background-color:black\"></BODY></HTML>";
webBrowser1.DocumentText=“”;

使用控件
System.Windows.Forms.WebBrowser
,您可以使用
文档文本预览HTML

例如:

webBrowser1.DocumentText = "<HTML><BODY style=\" background-color:black\"></BODY></HTML>";
webBrowser1.DocumentText=“”;

您的意思是“根本不在磁盘上”,还是“不生成将被持久化的文件”?如果是后者,您可以生成一个临时文件,该文件可以正常工作。如果要执行此操作,可以使用System.IO.Path.GetTempFileName()+“.html”;您的意思是“根本不在磁盘上”,还是“不生成将被持久化的文件”?如果是后者,您可以生成一个临时文件,该文件可以正常工作。如果要执行此操作,可以使用System.IO.Path.GetTempFileName()+“.html”;问题是针对asp.Net的,否则这将是一个好建议。问题是针对asp.Net的,否则这将是一个好建议。您知道我如何在其他选项卡或窗口中打开它吗?因为“Response.Write()”在同一个窗口中打开……您知道如何在其他选项卡或窗口中打开它吗?因为打开的“Response.Write()”位于同一窗口中。。。