【发布时间】:2011-05-12 20:22:06
【问题描述】:
我有一个在 IIS 7 中运行的 HTTPModule,它提供了许多不同的 URL 重写服务。
例如:
public void Init(HttpApplication context)
{
...
HttpContext.Current.RewritePath(landingPage.NewPath,
string.Empty,
landingPage.NewQueryString +
((landingPage.NewQueryString == string.Empty) ? "" : "&") +
queryString);
...
}
我有一个子应用程序,它有自己的用 MVC 编写的应用程序池:http://www.SomeSiteWithURLrewrite.com/SubMVCApplication/
这个模块很好用,除了作为子应用程序创建的 MVC 应用程序。
当我发出将被重写的 http 请求时:http://www.SomeSiteWithURLrewrite.com/Arbitrary/Path/To/Be/Rewritten
我收到 HTTP 错误 404.0 - 未找到
404 错误页面显示有对“http://www.SomeSiteWithURLrewrite.com/Arbitrary/Path/To/Be/Rewritten”的调用已被重写为物理路径“C:{RootDirectory}\ SubMVCApplication\" 与 "StaticFile" 的处理程序。
我不确定为什么管道没有将“HttpContext.Current.RewritePath”识别为 MVC 请求。是因为 MVC 应用在自己的应用中吗?
如何调用 RewritePath(或类似名称)并让 IIS 在子应用程序中呈现 ASP.Net MVC 页面
【问题讨论】:
标签: c# model-view-controller iis-7 httpmodule url-rewriting