Hi, I have this script :
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me?fields=email,name', function (response) {
console.log('Successful login for: ' + response.name);
// should redirect logger to ExternalLogin
//window.location.href = "/Account/ExternalLogin.cshtml";
//document.getElementById('status').innerHTML =
// 'Thanks for logging in, ' + response.name + '!';
});
Should after that line :
console.log('Successful login for: ' + response.name);
I will redirect to view Account/LoginExternal.cshtml.
I tried to add this code of line
window.location.href = "/Account/ExternalLogin.cshtml";
But it is not working for me. how can I do that. Thanks.
You cannot call View directly, I think you need to clear your concepts of MVC first.
You need to call ActionMethod which will return a view, so it must be like
window.location.href = "/Controller/ActionMethod";
If an ActionMethod is ExternalLogin is in Account controller which returns ExternalLogin.cshtml, like below
public ActionResult ExternalLogin()
{
// Some C# code
return View()
}
You can have JS to redirect
window.location.href = "/Account/ExternalLogin";
This is the correct way.
Hi, Neena Thanks a lot of for your answar.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly