I have a masterpage on which ill check for a condition if condition is true i want to redirect it to a particular view. how can i do this because on masterpage either view() or RedirectToAction() function a开发者_JAVA技巧re available. My condition is
if(Session["Name"]==null)
//redirect to login
else
//work as usual
you would typically do it in your controller...
alternatively if it is for authentication you can use:
FormsAuthentication.RedirectToLoginPage()
You can use the good old <% this.Response.Redirect("/controller/action"); %>
Be aware that redirection logic have to be in your controller, not your view.
A nice way to redirect from masterpage is
<% if(Session["abcd"]==null) {
Response.Redirect(Url.Action("actionname","controllername")
} %>
精彩评论