http上下文。 current.user.identity.name 为空
我正在尝试将 httpcontext.current.user.identity.name 的值与存储在我的 sql 数据库表中的值进行比较。它在我的本地机器上运行良好。但是,当服务器上托管同一网站时,httpcontext.current.user.identity.name 返回空。在 IIS 中,“允许匿名访问”已启用,但我不想禁用它。网上有很多解决方案,但我找不到适合我要求的解决方案。
I am trying to compare values of httpcontext.current.user.identity.name with the values stored in my sql database table. It works fine in my local machine. But httpcontext.current.user.identity.name is returning empty when the same website in hosted on server. In IIS "Allow anonymous access" is enabled and i don't want to disable it. There are many solutions available online but i am not able to find the once that's suits my requirement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您是否尝试过设置 AuthCookie?
现在您应该能够在代码中的其他位置使用以下内容:
Have you tried setting the AuthCookie?
Now you should be able to use the following elsewhere in your code: