Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 670567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:16:42+00:00 2026-05-14T00:16:42+00:00

I’ve never used HTTP Handlers before, and I’ve got one working, but I’m not

  • 0

I’ve never used HTTP Handlers before, and I’ve got one working, but I’m not sure if I’m actually using it properly. I have generated a string which will be saved as a CSV file. When the user clicks a button, I want the download dialog box to open so that the user can save the file. What I have works, but I keep reading about modifying the web.config file and I haven’t had to do that.

My Handler:

private string _data;
private string _title = "temp";


public void AddData(string data)
{
    _data = data;
}



public bool IsReusable
{
    get { return false; }
}

public void ProcessRequest(HttpContext context)
{

    context.Response.ContentType = "text/csv";
    context.Response.AddHeader("content-disposition","filename=" + _title + ".csv");
    context.Response.Write(_data);
    context.Response.Flush();
    context.Response.Close();

}

And this is from the page that allows the user to download:
(on button click)

string dataToConvert = "MYCSVDATA....";

csvHandler handler = new csvHandler();
handler.AddData(dataToConvert);

handler.ProcessRequest(this.Context);

This works fine, but no examples I’ve seen ever instantiate the handler and always seem to modify the web.config. Am I doing something wrong?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:16:42+00:00Added an answer on May 14, 2026 at 12:16 am

    It seems to me that it’s not really using the fact that it’s a handler at all. What is the benefit in making a separate class for this implementing an interface you don’t really use, rather than putting the code within your existing page class? You’re only doing things to the response – so why not just do that within the page?

    The typical approach of modifying web.config is because you want the handler to actually handle the request – whereas in your case the page is receiving the request, and just asking an object which happens to implement the handler interface to dump the data into the response.

    In particular, would this handler be usable at all as a standalone handler for a normal response? It feels like it’s only going to do anything useful when you’ve called AddData on it… if you did register it in web.config, it would just respond with an empty csv file (or possibly an exception), right? If that’s the case, I really don’t think it should implement the IHttpHandler in the first place – it will mislead other developers who look at it later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.