tags:

views:

36

answers:

3

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 are available. My condition is

if(Session["Name"]==null)
//redirect to login
else
//work as usual
A: 

you would typically do it in your controller...

alternatively if it is for authentication you can use:

FormsAuthentication.RedirectToLoginPage()
Dusty Roberts
A: 

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.

Branislav Abadjimarinov
A: 

A nice way to redirect from masterpage is

 <% if(Session["abcd"]==null) {
 Response.Redirect(Url.Action("actionname","controllername")
 } %>
Fraz Sundal