Reputation: 55210
I have this controller
[HttpPost]
public ActionResult Compose(ComposeMessage composeMessage)
{
var message = "";
dynamic fbPost = new ExpandoObject();
fbPost.message = composeMessage.Message;
dynamic result = FBHelper.PostInFacebook(fbPost, associatedAccount.ProviderAccessToken);
if (((IDictionary<String, object>)result).ContainsKey("error"))
{
Session["PostMessage"] = fbPost;
var redirectUrl = FBHelper.GetLoginUrl("email,read_stream,publish_stream");
//HttpContext.ClearError();
//the below redirect does not work
Redirect(redirectUrl);
//message = "Posting to Facebook failed. \n";
}
else
{
message = "Posting to Facebook successful. \n";
}
return Json(new { success = message });
}
Here what I am trying to do basically is to Redirect to Facebook OAuth if my access token is expired.
But the code Redirect(redirectUrl);
does not fire at all. My questions are
Upvotes: 1
Views: 592
Reputation: 24383
You need to return the redirect ActionResult
:
return Redirect(redirectUrl);
Upvotes: 1
Reputation: 3505
I think its becouse [HttpPost] attribute. You can pass your url to client and the call navigate(), or window.location = myurl.
Upvotes: 1