asp.net – MVC5认证中的“和主域之间的信任关系失败”
|
我有一个ASP.NET MVC5应用程序,其中我不使用Windows身份验证。 一切都运行正常,直到我尝试运行应用程序在它正在开发的域之外(无论什么原因)得到: The trust relationship between this workstation and the primary domain failed. 当我试图做User.IsInRole(“管理”)。 我正在使用.NET的 有关这个问题的很多问题,但他们来自想要使用Windows认证的人。并在他们的MVC应用程序中冒充: > With windows authentication,The trust relationship between the primary domain and the trusted domain failed,when calling IsInRole 那么为什么我得到这个SystemException如果我没有使用Active Directory和(据我所知)没有做任何可能依赖于PC的域名?我错过了一些配置(在我的Web.config或IIS Express中)? 编辑: 好的,把它缩小一点… 我的User.IsInRole(“Admin”)行位于我的_Layout.cshtml视图中的if()语句里面(即根据角色知道在nav。bar中显示的内容)。 我现在知道,当没有用户进行身份验证时,我只收到上面的错误,而且我不在我用于开发者的域中。如果我在该行放置一个断点,我可以看到User对象是一个System.Security.Principal.WindowsIdentity,其底层的Identity是System.Security.Principal.WindowsIdentity。 另一方面,如果用户被认证,那么User对象和ts Identity就是System.Security.Claims.ClaimsPrincipal和System.Security.Claims.ClaimsIdentity。 为什么会使用Windows身份(当未经身份验证),如何禁用它? 解决方法所以,根据我的编辑,我修改了我的_Layout.cshtml,而不是拥有@if(User.IsInRole("Admin")) {...}
我有 @if(User.Identity.IsAuthenticated && User.IsInRole("Admin")) {...}
这似乎解决了这个问题。 我相信问题是,当没有用户被认证时,ASP.NET身份使用了empty 但是,即使上面的更改似乎修复了我的代码,我将非常有兴趣了解更多关于此行为:为什么当没有用户被认证时,它使用一个空的System.Security.Principal.WindowsIdentity。我会接受任何解释的答案。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – How2:在HttpModule中挂钩的事件,用于将js链接放
- 构建ASP.NET应用程序 – 最佳实践
- asp.net-mvc – asp.net mvc中的动态子域
- asp.net – 如何在web.config中指定根(/)位置?
- asp.net-mvc – ASP.NET MVC V2 – 好友类
- asp.net-mvc – 如何包括一个模型与RedirectToAction?
- asp.net-mvc – User.Identity.Name在ASP.Net MVC中为空
- asp.net – MVC Controller返回Chunked内容编码
- asp.net-mvc – 使用linq2sql在c#mvc中不显示所选项的多选列
- asp.net-mvc – 在哪里可以找到C#示例代码来实现ASP.NET MV
- asp.net 文件上传与刷新与asp.net页面与iframe之
- .net – 如何创建一个dotnet核心单个可执行文件
- asp.net – 发送多个模型以查看MVC 4
- asp.net-mvc – 获取当前用户的角色
- asp.net – OutOfMemoryException当发送大文件50
- .net – 是否必须在自定义实现中覆盖默认的成员资
- asp.net-mvc – Umbraco 7自定义cookie
- asp.net-mvc – Unity.MVC4懒惰在ASP.NET MVC应用
- .net – App_LocalResources如何使用MVC?
- asp.net – 如何在WebGrid中的列标题使用Display
