protected void Page_Load(object sender, EventArgs e) { try { NetworkCredential NetCredentials = new NetworkCredential(); NetCredentials.UserName = ConfigurationManager.AppSettings["UserName"]; NetCredentials.Password = ConfigurationManager.AppSettings["Password"]; if (Request["OrderNo"].ToString() != "") { Web_Order_Mail objser = new Web_Order_Mail(); objser.UseDefaultCredentials = true; objser.Credentials = NetCredentials; string str = ConfigurationManager.AppSettings["FilePath"] + objser.OrderConfirmationPrint(Convert.ToString(Request["OrderNo"].ToString())); Response.Clear(); Response.ContentType = "application/pdf"; Response.WriteFile(str); Response.Flush(); } } catch (Exception ex) { var message = new JavaScriptSerializer().Serialize(ex.Message.ToString()); var script = string.Format("alert({0});", message); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true); } }