I have a private function like this in my controller.
private UserDetails GetUserDetails(int userid)
{
...
if (some condition check is false)
Redirect("some other page in a different subdomain");
return userDetails;
}
If the condition fails, Redirect statement is executed, but the execution doesn’t stop. userDetails is returned to the calling function. There is no redirect to some other page.
How can I force the redirect?
Redirect returns a result – you’re meant to use it from within an Action method as follows:
It looks like you should return null from the function you posted above, then check for null and
return Redirect("...")if GetUserDetails returned null.