I have a problem with Ajax.BeginForm. I have a form with submit and button that updates partial view.
What I am trying to accomplish is that I could use following return statements in the same Action.
// button activates this
return PartialView("PartialViewName", data);
and
// submit activates this
return Redirect(model.Url);
Now the problem is that Redirect causes problems to the Ajax.BeginForm
<% using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { OnSuccess = "OnSuccess", UpdateTargetId = "Container", InsertionMode = InsertionMode.Replace }, new { id = "eventAjaxForm" })) { %>
How can I identify is the result PartialView or are we redirecting user?
Normally when you perform an AJAX call to a controller action any redirects are followed until the client gets 200 status code or an error. So the HTML of the url you are redirecting to will be placed in the
Containerdiv. On the other hand in your controller action you could test whether the call was asynchronous usingRequest.IsAjaxRequest()and return a partial.