【发布时间】:2017-09-20 04:56:43
【问题描述】:
我开发了一个 asp.net,c# 应用程序。在那个应用程序中,我有一个任务,比如打开 excel 文件,我在开发 Visual Studio 时完成了任务,它在本地工作正常。
但是当我将我的应用程序托管到 IIS 服务器时,当我单击读取按钮时它没有响应。
我的 IIS 版本 - 7.5.7600
Asp.Net 代码:
<asp:TemplateField HeaderText="Read">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lnkKpiName" Text='✉ Read' CommandName="View" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CssClass="label" ForeColor="Green"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
C# 代码:
if (e.CommandName == "View")
{
LinkButton lnkBtn = new LinkButton();
lnkBtn.Attributes.Add("target", "_blank");
int index = Convert.ToInt32(e.CommandArgument);
string FileName = ((Label)gvwUserManual.Rows[index].FindControl("lblFileName")).Text;
ProcessStartInfo sInf = new ProcessStartInfo();
sInf.FileName = "EXCEL.EXE";
string XlsPath = Server.MapPath(@"~/SupportDocuments/" + Request.Cookies["BCookies"]["SessionUserName"].Trim().ToString() +"/" + FileName);
sInf.Arguments = XlsPath;
Process.Start(sInf);
}
我是否有权通过 IIS 打开 excel 文件?
【问题讨论】:
-
为什么要在服务器上的 IIS 中打开 excel 文件?为什么?您需要的是让您的用户下载它,而不是在 IIS 中打开。当我看到
ProcessStartInfo一面大红旗升起