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 7912113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:30:22+00:00 2026-06-03T13:30:22+00:00

I’m having trouble getting my ASP.Net page to return CSV on submit being clicked.

  • 0

I’m having trouble getting my ASP.Net page to return CSV on submit being clicked. Here’s the asp button definition I have for the submit button in Form.aspx:

<asp:Button id="submitreport" name="submitbutton" text="submit" OnClick="Report_Submit" runat="server" />

And this is the corresponding function in Form.aspx.cs:

public void Report_Submit(object sender, EventArgs e) {
    Debug.WriteLine("GETS HERE?");
    Response.Charset = "UTF-8";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetAllowResponseInBrowserHistory(true);
    Response.ContentType = "text/csv";
    Response.AddHeader("Content-Disposition", "attachment; filename='" + DateTime.Today.ToString() + ".csv'");
    Response.Write("test,output");
    Response.End();
}

When this is ran in Visual Studio I don’t even see the debug print line. Does anybody know what’s wrong with my setup?

Edit: I know for certain that the pages are set up right because if I put a breakpoint on my empty Page_Load function in Form.aspx.cs VS does break there. Besides that the breakpoint at the debug write line is skipped over on the form submit and the same page is returned again.

Update By creating a new project with just the button and the handler the Report_Submit() function is called and the CSV file is correctly generated. Since that narrows it down a little bit, does anybody know what could be going on in my other VS 2008 project that’s causing this not to work?

  • 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-06-03T13:30:25+00:00Added an answer on June 3, 2026 at 1:30 pm

    I found a pretty good work around that returns a .csv file (which also shouldn’t be quoted in my header creating function calls, but that wasn’t the problem). In addition, the shouldn’t specify a name since ASP.NET fills that in, but that also wasn’t the problem.

    Moving just the relevant form processing code into its own project worked just fine, but my project was too large to manage that.

    The workaround I found useful is to just move the button handling function into Page_Load() and use:

    if(Request.HttpMethod == "GET") {
        Debug.WriteLine("this is just a request for the page"):
    }
    else if(Request.HttpMethod == "POST") {
        Debug.WriteLine("processing the form");
        //rest of code...
    }
    else {
        //some HTTP action that doesn't matter
    }
    

    to distinguish page requests (GET) from users entering the form (POST requests).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and

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.