简体   繁体   中英

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).

-IIS reverse proxy setup with /subdirectory of siteA pointing to siteB domain.

-IIS rewrite module has been moved to the top of IIS modules list for siteA.

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. No other folders, files, etc. This testsiteA works fine in that the rewrite rule works as imtended. 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. Instead, the application_error handler is reached in the global.ascx and processing of the URL rewrite rule is not processed. I've tried to do Response.End(), clearing server errors, basic 'return;' statement to end execution, all in the application_error handler but none have worked.

How do I get IIS or the asp.net pipeline to process the URL rewrite as top priority?

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). To resolve this and let the URL rewrite be processed I simply added a

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

to the RouteConfig.cs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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