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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:02:41+00:00 2026-05-13T14:02:41+00:00

I writing a WCF Service that need transfer large files, so i using streaming,

  • 0

I writing a WCF Service that need transfer large files, so i using streaming, but from the other hand i need to do username specific initializations.

The problem is that getting the username and perform initialization every time is very expensive. If i could turn on session, i could just save initialized data in local variables in the service instance.

Is there a way to turn on both streaming and session in netTcpBinding?

  • 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-13T14:02:41+00:00Added an answer on May 13, 2026 at 2:02 pm

    Large file transfers are indeed a problem in wcf and the streaming option does not solve anything (you even need more memory on the server).

    If you don’t want to use sockets can solve the problem with implementing your own “protocol” for splitting up the file in blocks and transfer only separate blocks. I used reliableSessions and TransportWithMessageCredential.

    The Server (or client) interface looks something like this:

    [ServiceContract(CallbackContract = typeof(IClient), SessionMode = SessionMode.Required)]
    public interface IServer
    {
        [OperationContract]
        FilePart GetFileChunk(string identifier, int number, int blockSize);   
    }
    

    As DataContract you can use something like this:

     [DataContract]
    public class FilePart
    {
        [DataMember] public int Part;
        [DataMember] public byte[] Data;
        [DataMember] public int BlockSize;
    }
    

    To find the “right” block size you have to play around a little, i recommend something about 64-512 kb. When they are too small you have a lot request, when they are to large it gets slow and you have more load on the server side.

    It’s also important that the maxReceivedMessageSize, maxBufferSize, and the timeouts are high enough (in the binding configuration) and the reader quotas. For testing i recommend to use the maximum for all the fields, when it works use values that better fits.

    If you work with duplex bindings you can pass objects with by ref. With this way you can pass callback objects, so you are better able to view the progress of the transfer and so on…

    [OperationContract IsOneWay=true]
    FilePart GetFileChunk(string identifier, int number, int blockSize, ref TransferState callback);   
    

    I think this are all tricks and hints I can give. I hope it helps.

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

Sidebar

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.