I'm refactoring a website using an external service for a form submission, and once they send me the form data, they expect a string of in http response to let them know I've received their POST.
This was what's there previously, when the website was in web forms/aspx.
Response.ContentType = "text/plain";
Response.Output.Write("OK");
Response.Output.Flush();
Response.Output.Close();
So I tried this first in my controller:
public ActionResult Index()
{
//...get the form data...
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
But this didn't seem to work. Then I tried:
public ActionResult Index()
{
//...get the form data...
Response.StatusCode = 200;
Response.StatusDescription = "OK";
return new HttpStatusCodeResult(HttpStatusCode.OK, "OK");
}
And it still didn't work. I don't know if they get the 200 and didn't get the "OK" string?
EDIT: By didn't work, I meant that the external service didn't receive my string of "OK".
Simple as:
return Content("OK", "text/plain");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With