简体   繁体   English

带有ASP.NET MVC站点的IIS反向代理

[英]IIS reverse proxy with asp.net MVC site

Setup: 设定:

-Asp.net MVC website (siteA) with application_error handler implemented in global.ascx and only one Rule in the web.config (the reverse proxy rewrite rule). -Asp.net MVC网站(siteA),具有在global.ascx中实现的application_error处理程序,并且在web.config中只有一个规则(反向代理重写规则)。

-IIS reverse proxy setup with /subdirectory of siteA pointing to siteB domain. -IIS反向代理设置,其中siteA的/ sub目录指向siteB域。

-IIS rewrite module has been moved to the top of IIS modules list for siteA. -IIS重写模块已移至siteA的IIS模块列表的顶部。

Problem: 问题:

The reverse proxy configuration works on a testsiteA that has nothing in it the IIS folder except the iis rewrite rule in the web.config. 反向代理配置可在testsiteA上使用,该站点中的IIS文件夹中没有任何内容,但web.config中的iis重写规则除外。 No other folders, files, etc. This testsiteA works fine in that the rewrite rule works as imtended. 没有其他文件夹,文件等。此testsiteA可以正常工作,因为重写规则可以按预期进行。 However, when I apply the same rule to the real site, siteA, that has an asp.net MVC website Hosted the rewrite rule is never processed. 但是,当我将相同的规则应用于具有asp.net MVC网站托管的真实站点siteA时,将永远不会处理重写规则。 Instead, the application_error handler is reached in the global.ascx and processing of the URL rewrite rule is not processed. 而是在global.ascx中到达application_error处理程序,并且不处理URL重写规则。 I've tried to do Response.End(), clearing server errors, basic 'return;' 我试图做Response.End(),清除服务器错误,基本的“返回”; statement to end execution, all in the application_error handler but none have worked. 语句结束执行,所有操作都在application_error处理程序中,但没有一个起作用。

How do I get IIS or the asp.net pipeline to process the URL rewrite as top priority? 如何获得IIS或asp.net管道来处理URL重写作为最高优先级?

After adding some logging (I couldn't get the error handler to invoke in debug mode), I found our controller IoC couldn't resolve the subdirectory path (I also removed it from disk where it had been). 添加一些日志记录后(我无法获得错误处理程序以调试模式调用),我发现我们的控制器IoC无法解析子目录路径(我还从原来的磁盘中将其删除了)。 To resolve this and let the URL rewrite be processed I simply added a 要解决此问题并处理URL重写,我只需添加一个

routes.IgnoreRoute("subdirectory/{ }pathInfo }"); route.IgnoreRoute(“ subdirectory / { } pathInfo }”);

to the RouteConfig.cs. 到RouteConfig.cs。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM