美好的一天。尝试在 mod_mono 上运行 asp mvc。看起来没问题,但是当我尝试进入登录页面时,看到 500 内部错误:
System.TypeLoadException Could not load type 'System.Web.Security.MembershipPasswordAttribute' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.
Exception stack trace: at System.Web.Mvc.DataAnnotationsModelValidatorProvider..cctor () [0x00000] in :0
使用身份验证模式“表单”。
项目文件:
Microsoft.Web.Infrastructure.dll
System.Web.Helpers.dll
System.Web.Mvc.dll
System.Web.Razor.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll
存在于bin文件夹中
有人可以解决这个问题吗? 谢谢。
最佳答案
这是因为运行时尚未实现 System.Web.Security.MembershipPasswordAttribute(截至 2014 年 5 月 12 日)。您可以通过http://www.go-mono.com/status/status.aspx?reference=4.5&profile=4.5&assembly=System.Web查看需要做什么。
您可以实现自己的。如果您使用的是 Mono 3.4 版本,那么您应该从 3.4 分支获取代码。类库位于 [mono-code-root]/mcs/class/
下您将看到 System.Web.Security.MembershipPasswordAttribute 不存在(也可能是 System.ComponentModel.DataAnnotations.UrlAttribute)。您必须创建这些类并确保它们有效。然后制作并安装它。
您可以在此处查看更多信息:http://www.mono-project.com/Contributing#Contributing_to_the_Class_Libraries 也在这里:http://blog.neteril.org/blog/2013/08/11/the-very-basic-guide-to-contribute-to-mono-bcl/
我在 Mac 上尝试使用 Mono 开发 MVC5 项目时也遇到了这个问题。我有代码,您可以从这里获取它:https://github.com/nonagon-x/mono/tree/mono-3.4.0-mvc5-support如果您使用的是 mono 3.4.0
请注意,我添加的代码不适用于生产。我刚刚做到了能够在我的 Mac 上开发 MVC5。那里没有 NUnit 测试。因此,请勿将其用于生产。
关于c# - Mod_Mono + ASP MVC 5 Framework 4.5 - System.Web.Security.MembershipPasswordAttribute 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23391448/