Depending on your logic, you might be able to control your application flow by using jQuery.ajax()
to handle errors.
// this will render the GET request on page load
$(function() {
$.ajax({
url: '/Some/PartialViewAction',
type: 'GET',
dataType: 'json', /*edit*/
success: function(xhr_data) { /*edit*/
// the following assumes you wrap
// your partial view in div id="myDiv"
$('#myDiv').html(xhr_data.html); /*edit*/
$('#myErrorDiv').html(xhr_data.error); /*edit*/
},
error: function() {
window.location.href='/Some/Error';
// or similar page redirecting technique
}
});
});
This will handle an error in the GET, but of course if you were to return some JSON or some other indicator in your action method, you could use the same window.location.href...
in the success
callback function.
Edit
Also see above edits to $.ajax
Your controller could do something like this:
public ActionResult PartialViewAction() {
// handle error
string message = "Evacuate, Immediately!";
// not certain the html will render correctly,
// but you could encode/parse/whatever easily enough
return Json(new { html = "<div>some html</div>", error = message },
JsonRequestBehavior.AllowGet);
}