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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:56:19+00:00 2026-06-14T01:56:19+00:00

How can I pass a dataset to a generic handler? I don’t want to

  • 0

How can I pass a dataset to a generic handler?
I don’t want to use session or viewstate to do that.

I’m trying to return an excel file converted from the input dataset as the response.

I’m already showing the dataset content as a report in one grid filtered with some criteria set by user. Since the query is expensive, I don’t want to execute the same in the handler too.

It would be even better if I could pass the dataset by reference to the handler?

  • 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-14T01:56:20+00:00Added an answer on June 14, 2026 at 1:56 am

    I couldn’t find any way to pass dataset to ashx other than creating an object of the handled class and assign to it. Then I called the object’s ProcessRequest method. It worked fine and the build was succeeded. But when I tried to publish the website, the code gave error that the classname could not be found. The code is just like given below.

    //this is working fine in VS (build succeeded and ProcessRequest returned the file!) 
    //but didn't compile only on publishing
    MyHandler handlerObj = new myHandler();
    handlerObj.DataSource = myDataset;
    handlerobj.ProcessRequest(Context);
    

    I solved the problem by replacing the generic handler with a normal c# class which has a method accepting the context and dataset. Then I called the method in the class, where I wrote my file stream into the Context.Response and it worked just fine. The class did just the same as the handler and no need to inherit from IHttpContext

    public void ProcessDownload(HttpContext context, DataSet DataSource)
    {
        context.Response.Clear();
        context.Response.ContentType = "application/vnd.ms-excel";
        MemoryStream file = getExcelMemStream(DataSource);
        context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", "myFile.xls"));
        context.Response.BinaryWrite(file.GetBuffer());
        context.Response.End();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an iPhone app that can display an image dataset and pass it
In JSF 2 you can pass around ids, Strings other things that can be
I know that I can pass a string as the second parameter to the
Is there any way that I can pass arguments in selector? example: I have
I know from here that I can pass an ignore option in the jQuery.validate
can we pass dataset to a web service method? If yes , then how?
how can we pass dataset to web service dynamically is this is best way?
I'm trying to figure how to correctly return a dataview. I noticed that if
We want to have a hosted C# web service in IIS that I can
I have a basic dataset stored in javascript that I want to filter based

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.