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

Related Questions

I've been working with jQuery and *.asmx web services lately, and I'm trying to
I am not able to call web service(asmx) from jQuery function. It is saying
I have created a custom SharePoint web service that was deployed to, and successfully
Since working with Exchange Web Services 2010 is a bit ridiculous, especially from anything
'Hi I am calling a web service from javascript/jquery as follows: function Test(userid) {
Working on trying out the market licensing service, and I'm running into a few
Working on an html5 app for a touchscreen windows xp computer that will be
I am working on creating a .asmx webservice to meet the specific needs of
I created an ASMX file with a code behind file. It's working fine, but
Working with a SqlCommand in C# I've created a query that contains a IN

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.