locked
local host to local host for test purposes-existing connection was forcibly closed by the remote host.. RRS feed

  • Question

  • User518677258 posted

    Hi I have one sight where I want to check the post logic . Both at this point are just VS projects.

    If I start both projects I have one on https://localhost:44326/ and the other at 44390

    However when I try to post data within the app or go external to the web at 44390  ( throws error as shown )

    Question - is it possible to test this way ? If so how ?

    Name Value Type
    InnerException {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.."} System.Exception {System.IO.IOException}

    using 

    using (var client = new HttpClient())
                {
                    client.BaseAddress = new  Uri("http://localhost:44390");  // what happens if create another client with new #

     System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;  // saw his on stack overflow but made no difference
                    var content = new FormUrlEncodedContent(new[]
                    {
                    new KeyValuePair<string, string>("bigString", "abcd- I am a big string")
                });
                    var result = await client.PostAsync("index", content);   // await client.PostAsync("~/RecPost", content);
                    string resultContent = await result.Content.ReadAsStringAsync();
                    Console.WriteLine(resultContent);
                }

    Thursday, December 31, 2020 9:47 PM

Answers

  • User711641945 posted

    Hi andrewcw,

    It could work well in my project.For this issue,I think you need check the url,I think it should be https://localhost:44390 not http://localhost:44390.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 1, 2021 2:46 AM