匿名访问 SharePoint 列表时出现 ThreadAbortException
在我正在使用的旧代码中,Web 服务访问 SharePoint 列表。
其中一些列表需要特殊权限,因此首次访问时需要用户凭据。
然而,在我向应用程序添加一些日志记录后,我注意到当用户第一次尝试调用 Web 服务时实际上会发生以下情况:
- Web 服务开始正常运行;
- 当项目需要特殊权限时,SharePoint 会发送 HTTP 401,该 HTTP 401 会变成 ThreadAbortException ;
- 向用户呈现凭证框;
- 登录后,再次调用 Web 服务,这次没有出现问题。
这本质上意味着在这种情况下,SharePoint 调用之前的代码会运行两次。
在运行任何代码之前显示凭据框的正确方法是什么?
IIS 的匿名访问是否应该被禁用?我怀疑是这样,但我在配置网络项目方面太缺乏经验,所以我感到困惑。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 ASP.Net 应用程序进行重定向时,ThreadAbortException 是正常的。在这种情况下,您正在调试,因此您捕获了异常。
最好的建议是忽略该错误,因为它是预期异常。
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.