• Register
0 votes
121 views

Problem :

I am trying to use the WCF4.0 template -REST. Also I am trying to make the method that uploads a file using the stream.

The problem always occur at below line of code:

Stream myserverStream = myrequest.GetRequestStream();

My Class for streaming as below:

namespace LogicClass

{

    public class MyStreamClass : IStreamClass

    {

        public bool MyUploadFile(string myfilename, Stream myfileStream)

        {

            try

            {

               FileStream myfileToupload = new FileStream(myfilename, FileMode.Create);

                byte[] mybytearray = new byte[10000];

                int mybytesRead, mytotalBytesRead = 0;

                do

                {

                mybytesRead = myfileStream.Read(mybytearray, 0, mybytearray.Length);

                    mytotalBytesRead += mybytesRead;

                } while (mybytesRead > 0);

              myfileToupload.Write(mybytearray, 0, mybytearray.Length);

                myfileToupload.Close();

                myfileToupload.Dispose();

            }

            catch (Exception myex) { throw new Exception(myex.Message); }

            return true;

        }

    }

}

My REST project as below:

[WebInvoke(UriTemplate = "AddStream/{filename}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]

public bool AddStream(string myfilename, System.IO.Stream myfileStream)

{

    LogicClass.FileComponent myrest = new LogicClass.FileComponent();

    return myrest.AddStream(myfilename, myfileStream);

}

 

I have already turned off the firewall and my Internet connection, however the error still exists. Can anyone suggest a better way of testing the uploading method?

My Stack trace as below:

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Here you do not have to restart your PC. Restart the IIS instead.

Run -> 'cmd'(as admin) and type "iisreset"

 Your issue will be resolved.

9 7 4
38,600 points

Related questions

0 votes
1 answer 37 views
37 views
Problem : Why I got the error: [winerror 10061] No connection could be made because the target machine actively refused it.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 55 views
55 views
7 I have a problem with these client and server codes, I keep getting the [Errno 10061] No connection could be made because the target machine actively refused it I'm running the server on a virtual machine with Windows XP SP3 and the client on Windows 7 64bit, my python version is ... msg) msg = s.recv(1024) print 'SERVER >> ', msg #s.close # Close the socket when done PS : code is from internet.
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 3.9K views
3.9K views
Problem : I am facing the issue with the client and server codes, I keep on getting the [Errno 10061] No connection could be made because the target machine actively refused it I am running the server on a VM with Windows XP SP3 and my client is on Windows 7 64bit, also my python ... ('CLIENT >> ') s.send(msg) msg = s.recv(1024) print 'SERVER >> ', msg #s.close # Close the socket when done
asked Nov 21, 2019 peterlaw 6.9k points
0 votes
1 answer 6 views
6 views
Problem: The service call returns the message: System.ServiceModel.ServiceActivationException: The requested service, 'http://localhost:83/ABCStaticData/StaticDataService.svc' could not be activated. See the server's diagnostic trace logs for more information.
asked Mar 20 ummesalma 22.7k points
1 vote
1 answer 23 views
23 views
Problem: I am having fundamental knowledge on C#. Currently I am unable to connect to the HTTPS server with the use of WebRequest as I am facing below error message: "The request was aborted: Could not create SSL/TLS secure channel." I understand that my ... my server never really validates a certificate and it fails with a above error. Kindly guide me in fixing above certificate related error.
asked Jun 30, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 450 views
450 views
Problem : Facing bellow error the server committed a protocol violation. section=responseheader detail=cr must be followed by lf
asked Nov 8, 2019 peterlaw 6.9k points
0 votes
1 answer 8 views
8 views
Problem: After debugging and installing windows service in windows 8 I have an error when I try to start a windows service:"The Windows could not start service on local computer Error 5 Access is denied"
asked Mar 8 ummesalma 22.7k points
0 votes
1 answer 3 views
3 views
Problem: I'm trying to connect to my database from my java application, but it refuses the connection, the error given is this one: Telnet connect to address 127.0.0.1 connection refused
asked Mar 21 ummesalma 22.7k points
0 votes
1 answer 29 views
29 views
Any suggestions on what could be?
asked Jan 24 TeamScript 13.5k points