关于 asp.net 的 Word 打印
大家好,碰到一个奇怪的问题,正在做一个word打印的功能,用window.open("printTemp.aspx")打开以下页面,即打印预览。在ie6与firefox中均正常,在ie7中却有问题,打开的弹出窗口不到二秒钟就自动关闭,请问,这是什么问题?万分感谢
printTemp.aspx.cs 代码如下 :
#region
using System;
using System.IO;
using System.Text;
using System.Web.UI;
#endregion
public partial class CRM_PrintTemp : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string wordPath = "";
try
{
wordPath = Path.Combine(Server.MapPath("~"), @"upload\file\Print");
if (Request.QueryString["wordId"] != null)
{
wordPath += @"\UserPrint\" + Request.QueryString["wordId"].ToString() + ".doc";
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.ContentEncoding = Encoding.GetEncoding("GB2312");
Response.ContentType = "application/msword";
Response.WriteFile(wordPath); //指定文件路径
Response.Flush();
Response.Close();
}
}
catch (Exception)
{
}
try
{
File.Delete(wordPath);
}
catch
{
}
}
}
}