I have a Get
method
[Route("login/{code}")]
public class LoginController : Controller {
[HttpGet]
public void Login(string code) {
bool resp = TryToLogin(code);
if (resp == true) {
redirectToSiteOne;
} else {
redirectToSiteTwo;
}
}
}
And I don't understand how to make redirect to another site (there is must be redirect from api.example.com to example.com maybe it's important)
I found 2 methods to do that :
Method 1 - change void
return type to HttpResponseMessage
var res = Request.CreateResponse(HttpStatusCode.Moved);
res.Headers.Location = new Uri("https://www.google.com");
return response;
Method 2 - change void
return type to RedirectResult
return RedirectPermanent("https://www.google.com");
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments