如何使用C#从ASP.NET打开HTML报告 [英] How do I open a HTML report from ASP.NET using C#

查看:93
本文介绍了如何使用C#从ASP.NET打开HTML报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在该应用程序中有一个Web应用程序,同时单击我需要的HTML页面按钮。它已经创建了。我对asp.net不太熟悉。所以有人请提出一个主意。



我尝试了什么:



1


I have a web application in that application while clicking a button I need to my HTML page. it is already created. I'm not much familiar in asp.net. so someone please suggest an idea.

What I have tried:

1

string filepath = Server.MapPath("~/Report.html");
       string s = "window.open('" + filepath + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
       ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);





以上代码不工作

2

string filepath = Server.MapPath(〜/ Report.html);

流程p =新流程();

p.StartInfo.UseShellExecute = true;

p.StartInfo.FileName = filepath;

p.StartInfo.Verb =打开;

p.Start();

此代码在我的visual studio中工作正常,但它IIS中不支持



above code not working
2
string filepath = Server.MapPath("~/Report.html");
Process p = new Process();
p.StartInfo.UseShellExecute = true;
p.StartInfo.FileName = filepath;
p.StartInfo.Verb = "Open";
p.Start();
this code is working fine from my visual studio, but it do not support in IIS

推荐答案

Server.MapPath获取光盘上文件的路径名(c:\inetpub \wwwroot \ site \ report) .htm)在客户端没用,客户端需要一个html路径,所以你需要发送它,所以使用像



VirtualPathUtility.ToAbsolute Method(String)(System.Web) [ ^ ]



Server.MapPath gets the path name of the file on the disc (c:\inetpub\wwwroot\site\report.htm) which is no use on the client, the client needs an html path so you need to send that instead so use something like

VirtualPathUtility.ToAbsolute Method (String) (System.Web)[^]

string filepath = VirtualPathUtility.ToAbsolute("~/Report.html");


这篇关于如何使用C#从ASP.NET打开HTML报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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