In the legacy code I'm working with, a web service accesses SharePoint lists.
Some of these lists require special permissions so user credentials are requested at first access.
However after I added some logging to application I noticed that actually the following happens when user tries to call the web service first time:
- web service begins running normally;
- when item requires special permissions, SharePoint sends HTTP 401 which turns into
ThreadAbortException
; - user is presented with credentials box;
- after logging in, the web service is called once again, this time without problems.
It essentially means that code prior to SharePoint calls runs twice in this scenario.
What is the right way to show credential box before any code is run?
Is this the case when anonymous access is IIS should be disabled? I suspect so but I'm too inexperienced in configuring web projects so I feel confused.
The ThreadAbortException is normal when an ASP.Net application does a redirect. In this case, you are debugging so you catch the exception.
Best advice is to ignore the error as it is an expected exception.