How can I generate links to other MVC applications?

81 views Asked by At

I've created three related ASP.NET MVC web-applications that sit in IIS like so:

root
|-Emailing
|-InternalManagement

Where the root site is customer facing.

The three sites have different security requirements and I wanted to be able to modify one application with less worry about breaking the other two.

However both the root and the internal management site need to have links to the emailing site.

I'm using T4MVC.

Now I've separated the T4MVC helpers for each project by modifying the HelpersPrefix, and root and InternalManagement reference emailing so for example I can do something like:

Url.Action(MVCEmailing.CustomerDocuments.Index())

Which almost works - except the actual URL produced will be:

For the root application:

http://mydomain.com/CustomerDocuments/Index

for the internal management application:

http://mydomain.com/internalManagement/CustomerDocuments/Index

What I need in both cases is for the URL produced to look like so:

http://mydomain.com/emailing/CustomerDocuments/Index

What's the best way to go about doing this?

1

There are 1 answers

0
David Ebbo On

Copying from the T4MVC doc:

One key concept to understand about T4MVC is that it is just a thin layer over MVC. e.g. while it provides strong typing, in the end it's just putting values in a dictionary, and using standard MVC to generate the routes.

One thing I often suggest when people have questions is to first figure out how they would do things without T4MVC. If you have no idea how it would work, or think it may not be possible at all, then you are probably expecting too much of T4MVC! Generally, it will not do anything that MVC does not support.

In your case here, I'm not convinced that you could do this with plain MVC, because each of the application does not have knowledge of the other applications' routes. And generally, I don't think that MVC routing can ever general links that go outside of the current app.