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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:59:28+00:00 2026-05-11T07:59:28+00:00

I am working on an ASMX web service; trying to create a method that

  • 0

I am working on an ASMX web service; trying to create a method that will download a document from a server and show the document in the browser (the calling .aspx web page). My service builds without error but I get the following error when I try to ‘Add Web Reference’ in my Proxy class project:

System.Web.HttpResponse cannot be serialized because it does not have a parameterless constructor.

Here is a snippet of the code in .ASMX file:

public class FileService : System.Web.Services.WebService {     [WebMethod]     public void DownloadDocument(string URI, HttpResponse httpResponse)     {         int DownloadChunkSize = (int)Properties.Settings.Default.DownloadChunkSize;         // some more code here....         using (httpResponse.OutputStream)         {             // more code here...         }     } } 

I see I am confused about how to send back an HttpResponse from a web service to a requesting web page. Could someone please give me a tip on how to do this? 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. 2026-05-11T07:59:29+00:00Added an answer on May 11, 2026 at 7:59 am

    You should look into web handlers (.ashx). They are perfect for what you are trying to achieve.

    For example:

    public class Download : IHttpHandler, IRequiresSessionState {      public void ProcessRequest(HttpContext context) {         var pdfBytes = /* load the file here */         context.Response.ContentType = @'Application/pdf';         context.Response.BinaryWrite(pdfBytes);         context.Response.End();     } } 

    UPDATE: An ashx handler is actually a replacement to aspx. Basically, it has no UI but still processes get / post requests just like an aspx page does. The point is to reduce the overhead generated by running a regular aspx page when all you need to do is return some simple content (like a file…) or perform a quick action.

    The IRequiresSessionState interface allows you to use the SESSION object like any other page in your site can. If you don’t need that, then leave it off.

    This site has an interesting walk through on how to create one. Ignore Step 4 as you probably don’t care about that.

    Assuming that you have a regular page (aspx) that has a link to your document: The link in the aspx file would actually point directly to your ashx handler. for example:

    <a href='/document.ashx?id=blah'>Click Here</a> 

    Then the code in the ProcessRequest method of the ashx handler would do whatever calls it needed (like talk to your DLL) to locate the document then stream it back to the browser through the context.Response.BinaryWrite method call.

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

Sidebar

Ask A Question

Stats

  • Questions 85k
  • Answers 85k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm sorry, the question is not very clear.. Is that… May 11, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer NHibernate supports mutiple access strategies for class members. Public properties… May 11, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer Suggestion: $pk is not set. So try to use $_REQUEST['pk']… May 11, 2026 at 5:11 pm

Related Questions

I have an application that I am writing that modifies data on a cached
I am working on creating a .asmx webservice to meet the specific needs of
I'm working on an application that makes asynchronous calls to the WebService. I added
I am working on an ASP.NET project which is physically located at C:\Projects\MyStuff\WebSite2. When

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.