【发布时间】:2015-06-20 17:10:58
【问题描述】:
我在我的 asp.net web api 项目中使用 Simplemembership。当我尝试使用以下代码验证用户时,出现错误(错误 1)
if (!Membership.ValidateUser(username, password))
{
throw new ValidationException("Username or pwassword is incorrect.");
}
错误 1:
通过安全透明方法尝试 'WebMatrix.WebData.SimpleMembershipProvider。 ValidateUser(System.String, System.String)' 访问安全性 批判法 'System.Web.WebPages.StringExtensions.IsEmpty(System.String)' 失败。
早些时候我遇到了类似的错误(错误 2),我通过安装这些软件包解决了这个错误:
Install-Package Microsoft.AspNet.WebHelpers
Install-Package Microsoft.AspNet.WebPages.Data
错误 2:
通过安全透明方法尝试 'WebMatrix.WebData.PreApplicationStartCode.OnConnectionOpened( System.Object, WebMatrix.Data.ConnectionEventArgs)' 访问安全性 关键方法'System.Web.WebPages. HttpContextExtensions.RegisterForDispose(System.Web.HttpContextBase, System.IDisposable)' 失败。
我确实清理了解决方案并尝试了,仍然得到同样的错误, 我是否需要安装更多的软件包,甚至简单的会员资格在 web api 中是否有效?
【问题讨论】:
标签: validation authentication asp.net-web-api asp.net-mvc-5 simplemembership