简体   繁体   中英

IIS Redirect on error or when folder not converted to application

Is there anyway we can catch IIS performing the automatic redirect back to the main site or have IIS redirect them to an error page?

We have an MVC app that uses a sub-application to authenticate a user. Main application redirects user to sub-application which authenticates and returns them to main application.

The issue we are having is: in IIS, if a sub-application is not converted to an application, IIS automatically redirects the user back to the main application.

在此处输入图片说明

Because our application redirects users to sub-application to authenticate, when IIS redirects users back to main application without authenticating them, users get stuck in an endless loop where our main app redirects users to sub-app to be authenticated, IIS sees sub-app is not an application and redirects user back to main app and the cycle resets.

We are well aware that it is an IIS requirement to have this folder be an application but we need a way to detect this issue and handle it appropriately.

If can't be done, does anyone know of a configuration/event (or anything) that we can use to catch this error? In particular, it would be great if we could detect an IIS error or detect IIS not being able to access the sub app?

Any suggestions would be greatly appreciated.

Thanks!

Caveat: I haven't done this, so happy to be downvoted / retract if someone comes along with better info... But...

If I were to do this I would look at the programmatic administration of IIS (see: https://msdn.microsoft.com/en-us/library/aa347649(v=vs.90).aspx ).

And then, in my web application startup (global.asax or similar), check the local IIS install to ensure that the virtual applications exist as expected. If not, throw an error on my main application, and come down hard. You say that this sub application is a pre-requisite for your main application, so I wouldn't try to fail gracefully, I'd just crash (with a reasonable error), and log / notify, etc as appropriate.

I feel silly. For anyone else experiencing the same issue:

We had code (hidden layers deep) in Global.asax that was redirecting users, after much investigating (with help from comment by @John Wu) and research, I can confidently say IIS will not redirect to any page on any error.

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