Lostaunaum Lostaunaum - 1 year ago 81
C# Question

Verify application for Loader.Io testing

I am trying to do some load testing with

https://loader.io/

I am currently stuck at the stage of "verifying" my localHost application to make sure I am the one controlling it.

I have added this end point:

[HttpGet("/loaderio-a65421134i3ia3d110vcv0120d1ac14b/")]
[Authorize()]
public StreamReader GetLoaderIO()
{
var file = System.IO.File.OpenText(@"C:\Users\User\Downloads\loaderio-a65421134i3ia3d110vcv0120d1ac14b.txt");
return file;
}


When I run a GET request to this URL

http://localhost:5012/loaderio-a65421134i3ia3d110vcv0120d1ac14b/

I successfully step in my end point, what do I need to return in order for the LoaderIO to be happy? Do I have to return the stream so it can be downloaded?

enter image description here

Answer Source

I can see three potential issues with your code.

First, you are targeting a localhost address instead of a deployment address (i.e. http://yourapi.com or 159.254.102.69). To fix that issue you will need to either deploy your code somewhere or open http ports from your machine.

Second the file you are trying to retrieve my not be at the same location or might not even be accessible so a simpler way would be to write the string directly (done multiple time to verify on loader.io works like a charm) like below:

[HttpGet]
[Route("loaderio-a65421134i3ia3d110vcv0120d1ac14b")]        
public HttpResponseMessage GetLoaderIoVerification()        
{       
        var response = Request.CreateResponse(HttpStatusCode.OK);       
        response.Content = new StringContent("loaderio-a65421134i3ia3d110vcv0120d1ac14b", Encoding.UTF8, "text/plain");     
        return response;        
}

Finally, there is that Authorize attribute that will try to authenticate the loader.io request that needs to be a resource as accessible as this one: https://media4.giphy.com/media/LXONhtCmN32YU/giphy.gif In order to do so you will need to remove it.

Once those three points are corrected you will be able to verify your api for loader.io. Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download