I have an ASP.NET(3.5) web application. My app. generates excel/pdf reports for users.
I use Response.TransmitFile to make users download the report. It can take some time(~5 mins.) to produce a report. I don't want users to click "Report" button while report is generated.
I disable "Report" button in javascript when it is pressed but I cannot enable again after I use Response.TransmitFile.
I don't want to enable the button manually after some time in javascript or add a cookie to Response and check it continuously in javascript whether cookie is created or not.
Is there a way to deal with this by using HTTPHanlder or any other suggestions?
Yes you can done through httpHandler. Give Handler relative path to hyperlink. Send input parameters in query string.And access data from your storage. and write the content.
Yes you can done through httpHandler. Give Handler relative path to hyperlink. Send input parameters in query string.And access data from your storage. and write the content.
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
HttpResponse r = context.Response;
r.ContentType = "image/png";
//
// Write the requested image
//
string file = context.Request.QueryString["file"];
// Get Data From Database. And write file.
if (file == "logo")
{
r.WriteFile("Logo1.png");
}
else
{
r.WriteFile("Flower1.png");
}
}
public bool IsReusable {
get {
return false;
}
}
}
skosko
Member
6 Points
5 Posts
Using HTTPHandler for file downloading
Dec 26, 2011 08:44 AM|LINK
Hi All,
I have an ASP.NET(3.5) web application. My app. generates excel/pdf reports for users.
I use Response.TransmitFile to make users download the report. It can take some time(~5 mins.) to produce a report. I don't want users to click "Report" button while report is generated.
I disable "Report" button in javascript when it is pressed but I cannot enable again after I use Response.TransmitFile.
I don't want to enable the button manually after some time in javascript or add a cookie to Response and check it continuously in javascript whether cookie is created or not.
Is there a way to deal with this by using HTTPHanlder or any other suggestions?
Thanks.
httphandler
Thulasiram
Member
438 Points
93 Posts
Re: Using HTTPHandler for file downloading
Dec 26, 2011 02:26 PM|LINK
Yes you can done through httpHandler. Give Handler relative path to hyperlink. Send input parameters in query string.And access data from your storage. and write the content.
skosko
Member
6 Points
5 Posts
Re: Using HTTPHandler for file downloading
Dec 26, 2011 02:39 PM|LINK
Hi,
I am not familiar with HTTPHandler concept.
Could you share an example?
Thanks.
Thulasiram
Member
438 Points
93 Posts
Re: Using HTTPHandler for file downloading
Dec 26, 2011 03:12 PM|LINK
<asp:HyperLink id="hyperlink1" Text="Download" runat="server"/><%@ WebHandler Language="C#" Class="Handler" %> using System; using System.Web; public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { HttpResponse r = context.Response; r.ContentType = "image/png"; // // Write the requested image // string file = context.Request.QueryString["file"]; // Get Data From Database. And write file. if (file == "logo") { r.WriteFile("Logo1.png"); } else { r.WriteFile("Flower1.png"); } } public bool IsReusable { get { return false; } } }