IActionFilter Redirect in MVC3?

There are several ways to accomplish this - some good ways provided here: Redirecting to specified controller and action in asp.net mvc 2 action filter.

Up vote 1 down vote favorite share g+ share fb share tw.

I am implementing an IActionFilter to authenticate the request in MVC3, if my authentication returns false I want to redirect the request to a different controller from within the IActionFilter. I would like to be able to kill the processing of the current request and totally redirect the request to a different controller action. I am also willing to use the IAuthorizationFilter but this appears for the most part the same as the IActionFilter.

Thanks for the help. Asp. Net-mvc-3 link|improve this question asked Sep 29 '11 at 23:56John Maloney5818 67% accept rate.

There are several ways to accomplish this - some good ways provided here: Redirecting to specified controller and action in asp.net mvc 2 action filter In a nutshell you can either ctx.Response.Redirect() or create a new route as the result of your filter context. Ensure wherever you redirect to won't fail authentication though or you can get stuck in a loop unless you code in your specific url which is somewhat hacky. If you have a problem with this, post back we'll help you out, but that should work just fine.

Thanks Adam, your reference was actually the answer: @Richard filterContext. Result = new RedirectToRouteResult( new RouteValueDictionary {{ "Controller", "YourController" }, { "Action", "YourAction" } }); – John Maloney Sep 30 '11 at 0:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions