0

I have an MVC app that uses default routing: {area}/{controller}/{action}. It sits in back of a reverse proxy (IBM webseal, if it matters) that does authentication for me.

I have a need to have my application sit in back of a different reverse proxy which will cause views to be rendered differently. Here is an example

I have a route:

/RS/Contract/ContractDetails.

That renders a certain view, from behind reverse proxy #1.

Reverse proxy #2 uses a different area, which is called agent. It only has one URL:

/agent/home/agentaccess

The action method AgentAccess sets some flags that cause different layouts to be used, and ultimately redirects to the /RS/Contract/ContractDetails route listed above.

So far it's pretty simple. However, I've been told that when accessing my site through Reverse proxy #2, for security purposes, I can ONLY access the /agent area.

Obviously code duplication is out of the question. I don't want to duplicate the same logic and views in each area. What I'm looking to do, I think, is something akin to the old Server.Execute methods. I'd like to request /agent/home/agentaccess, and execute /RS/Contract/ContractDetails. I could use IController.Execute(), but that doesn't seem very MVC-ish or elegant to me. Is there something better? A way to tape into the routing system to influence what action methods get matched for a requested route would be ideal. Or any other ideas would be welcome.

Thanks!

Jeff

jeff.eynon
  • 1,296
  • 3
  • 11
  • 29
  • 1
    I don't understand, you want to receive request from regular route and redirect to another route? if you just want to reduce code duplication you can use Portable ares in MVC and make some controllers of maybe areas as shared types in your application. – Ehsan Feb 03 '14 at 17:45
  • Sorry, I know it's confusing. Remember Server.Execute() in web forms or way back in classic asp? you could call mysite.com/mypage.aspx and in the codebehind, "execute" myotherpage.aspx and return that as the output for calling mypage.aspx? It's basically like that. I don't want to redirect. I want to execute a completely different action method in response to a route. – jeff.eynon Feb 03 '14 at 19:52
  • http://stackoverflow.com/questions/483091/render-a-view-as-a-string/1241257#1241257, as described in the answer you can simply mess with the Response stream of the HttpContext and return the output for calling an action, hope it helps – Ehsan Feb 03 '14 at 20:13

0 Answers0