1

This question has already been asked here:

How to redirect from OnActionExecuting in Base Controller?

but what I don't like in the accepted answer there is that it triggers a new request meaning I run through the logic of the base controller all over again. So I would like to know if there is a way to intercept the request in base controller and based on some condition change the executing controller/action without causing a redirect and essentially going through a full request pipeline? I want the base controller to figure out if the application is setup properly and, if not, transfer control to SetupController's Index action without firing an entire new request?

Community
  • 1
  • 1
Marko
  • 12,543
  • 10
  • 48
  • 58
  • 1
    I remember I´ve used server transfer in the web forms long time ago, maybe this helps you out! http://stackoverflow.com/questions/799511/how-to-simulate-server-transfer-in-asp-net-mvc – pedrommuller Oct 17 '13 at 20:18
  • @Pedro This is working great for me there is only 1 issue I see. The browser URL address remains the same after server transfer executes. Is there a way to change the URL to where it matches the transfer address? – Marko Oct 21 '13 at 15:33
  • that´s one of the disadvantages (depending of the point of view), I think it could be possible to do but you´ll need to hack a url route (if available under that context) I remember that you are available to get the "original" url via rawurl – pedrommuller Oct 21 '13 at 16:23

1 Answers1

1
   filterContext.Result = new RedirectResult(url);
   return;