How to send a Status Code 500 in ASP.Net and still write to the response?
Context.Response.TrySkipIisCustomErrors = true
Context.Response.TrySkipIisCustomErrors = true
In the simplest terms, an ASP.NET HttpHandler is a class that implements the System.Web.IHttpHandler interface. ASP.NET HTTPHandlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. The most common handler is an ASP.NET page handler that processes .aspx … Read more
Create an ASHX (faster than aspx onload event) page, pass a the id of the file as a querystring to track each download public class FileDownload : IHttpHandler { public void ProcessRequest(HttpContext context) { //Track your id string id = context.Request.QueryString[“id”]; //save into the database string fileName = “YOUR-FILE.pdf”; context.Response.Clear(); context.Response.ContentType = “application/pdf”; context.Response.AddHeader(“Content-Disposition”, “attachment; … Read more
Implement the System.Web.SessionState.IRequiresSessionState interface public class Handler : IHttpHandler, System.Web.SessionState.IRequiresSessionState { public void ProcessRequest(HttpContext context) { context.Session[“StackOverflow”] = “overflowing”; context.Response.Redirect(“~/AnotherPage.aspx”); } }