IIS - ASP.NET MVC重定向 [英] IIS - ASP.NET MVC redirection

查看:202
本文介绍了IIS - ASP.NET MVC重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用ASP.NET MVC,各有多个控制器的两个应用程序。

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

我想要做的,从应用程序A到应用B重定向,但仅适用于应用程序A(一个控制器)的单一路线。

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

例如:

/ applicationA /问题/ *应该重定向到/ applicationB /问题/

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

/ applicationA /质量/不应该重​​定向

/applicationA/quality/ should not redirect

有关IIS重定向的示例都向我展示了如何点击一个文件/文件夹,并启用重定向的例子,但我试图做一个路由,而不是一个物理路径。

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.

我不希望修改ASP.NET源(如果可能的话)。

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

感谢。

编辑 - 这是在IIS6上WIN2K3

edit - this is in IIS6 on Win2k3.

推荐答案

是啊,这最后一点是一个真正的警告。如果这是在IIS7,它会更容易100%!

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

您可以下载其他应用程序做重定向的工作,但那就不是很难编辑MVC应用程序。假设/问题/和/质量/是不同的路线,为什么不这样做的:

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

这篇关于IIS - ASP.NET MVC重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆