views:

212

answers:

2

Hello,

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

I want to do a redirect from application A to application B, but only for a single route on application A (one controller).

Eg.

/applicationA/issue/* should redirect to /applicationB/issue/

/applicationA/quality/ should not redirect

The examples for IIS redirection are showing me examples of how to click on a file/folder and enable redirection, but I'm trying to do a route, not a physical path.

I don't want to modify the ASP.NET source (if at all possible).

Thanks.

edit - this is in IIS6 on Win2k3.

+1  A: 

You could use URLRewriting.NET to do the redirection based on a regex pattern.

Mitchel Sellers
I agree. As solution for IIS6, UrlRewriting.NET is probably the best there is. @Michael, the url that you might want to add to the answer is http://urlrewriting.net/149/en/home.html.
Dan Atkinson
@dan - Thanks, i added the link!
Mitchel Sellers
+1  A: 

Yeah, that last bit is a real caveat. If this were on IIS7, it'd be 100% easier!

You could download another app to do the redirecting work, but then it wouldn't be hard to edit the MVC app. Assuming that /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();
  }
}
Dan Atkinson
I was hoping to do it at the IIS level so it was explicit to anyone looking at the management tool. Looking at UrlRewriting I don't see the benefit of using it over just changing my MVC routes, which seems like the answer.
eyston
Added route to top of list, and then an action that returns a new RedirectResult. IIS7 seems to address this, but it was just easier in ASP.NET vs. IIS5/6.
eyston
Glad I could help!
Dan Atkinson