IIS Redirection - ASP.NET MVC

I have two applications using ASP.NET MVC, each with multiple controllers.

I want to make a redirect from application A to application B, but only for one route in application A (one controller).

Eg.

/ applicationA / issue / * should be redirected to / applicationB / issue /

/ applicationA / quality / should not be redirected

IIS redirection examples show me examples of how to click a file / folder and enable redirection, but I'm trying to execute a route, not a physical path.

I do not want to change the source of ASP.NET (if at all possible).

Thanks.

edit is in IIS6 on Win2k3.

+1
source share
2 answers

Yes, the last bit is a real caveat. If it were on IIS7, it would be 100% easier!

You can download another application to do the redirection, but then it would not be easy to edit the MVC application. Assuming / issue / and / quality / are different routes, why not just do something like this:

public class MyController { public RedirectResult Issue() { //return as a redirect return Redirect("http://applicationb/issue"); } public ActionResult Quality() { //This is here to show that, instead of redirecting, it returns a view. return View(); } } 
+1
source

You can use URLRewriting.NET to redirect based on a regular expression pattern.

+1
source

Source: https://habr.com/ru/post/914922/


All Articles