IIS - ASP.NET MVC redirection

不想你离开。 提交于 2019-12-23 01:35:22

问题


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:


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();
  }
}



回答2:


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



来源:https://stackoverflow.com/questions/1190488/iis-asp-net-mvc-redirection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!