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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:44:39+00:00 2026-05-28T05:44:39+00:00

I have WCF service running from within a Windows Service. This is working fine

  • 0

I have WCF service running from within a Windows Service. This is working fine and I am able to send/receive soap messages to the server.

The problem is I would also like to be able to access a static file (a simple download) from this same service (or more specifically from the same port, so that only one port needs to be internet accessible).

With my existing service, I have methods such as:

public interface IMyServerService
{
    [OperationContract]
    [WebInvoke]
    string ListValue(string arg1);
}

I have now tried to add the following:

    [OperationContract]
    [WebGet(BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/DownloadFile")]
    System.IO.Stream DownloadFile();

With the following implementation:

    public System.IO.Stream DownloadFile()
    {
        var context = System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse;

        context.Headers.Add(System.Net.HttpResponseHeader.CacheControl, "public");
        context.ContentType = "text/plain";
        context.StatusCode = System.Net.HttpStatusCode.OK;

        return new System.IO.FileStream(@"C:\test.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read);
    } // End of DownloadFile

My goal would be to access https://service/DownloadFile but when I try that I get a error 400.

I guess my questions would be, am I able to do this from inside the same WCF service, or should I create a second service to do so?

  • 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-28T05:44:40+00:00Added an answer on May 28, 2026 at 5:44 am

    You can, provided you set up the correct bindings (like the webHttpBinding for your new function). The question is, should you? Typically a ServiceContract groups together certain functionality. If this file downloading is something new that has nothing to do with the existing service, I’d create a new one.

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

Sidebar

Related Questions

I have a WCF service running inside a windows service on a remote machine.
I have a netTcp WCF service running in a windows service on a remote
I have a WCF Service running SOAP and allowing Flex / Flash to connect
I have WCF service running on netTcpBinding, everything fine I have some more functions
I just created a WCF service with this MSDN tutorial . from within Visual
We have a WCF RESTful service running and working great on IIS 7. Our
I have a WCF service console application. When I run it from within Visual
I have a wcf self-hosted service running as windows service, serving multiple win/web clients
I have a WCF service running inside Windows Service and it is located on
I have a WCF service running on my machine, which get lauched while I

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.