I have a service that calls API GET request and return boolean.
Task<bool> LoginExist(string email, string password);
In the controller, I have the code below:
[HttpPost]
public ActionResult Login(string email, string password)
{
System.Diagnostics.Debug.WriteLine("here");
bool login_result = _accountService.LoginExist(email, password).Result;
System.Diagnostics.Debug.WriteLine(login_result);
if (login_result)
{
FormsAuthentication.SetAuthCookie(email, false);
return Redirect(Request.UrlReferrer.ToString());
}
else
{ Redirect("Register"); }
return Redirect("Register");
}
However, when I test it, after I click Login, which triggers post request, I can tell GET is successfully executed in my flask api (it returns status 200), however, it never goes to the IF statement or ELSE statement in the code above. Instead, it just kept running...
I wonder if we can use GET within POST and if not, does anyone have better way to approach this?
I added what I have in service:
public async Task<bool> LoginExist(string email, string password)
{
string url = string_url;
LoginVerification str = await url.WithHeaders(new { Accept = "application /json", User_Agent = "Flurl" }).GetJsonAsync<LoginVerification>();
return str.login_valid;
}