asp.net-mvc – WebSecurity.InitializeDatabaseConnection方法
发布时间:2020-12-15 22:53:14 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试 Windows Azure来托管一个MVC4 Web应用程序. 我创建了一个测试应用程序,使用VS2012 MVC4互联网应用程序模板,并添加了一个自定义的模型和控制器. 我已经在Azure上发布了它,并设法将“update-database”应用于Azure数据库. 当我在本地尝试应用程序,
我正在尝试
Windows Azure来托管一个MVC4 Web应用程序.
我创建了一个测试应用程序,使用VS2012 MVC4互联网应用程序模板,并添加了一个自定义的模型和控制器. 我已经在Azure上发布了它,并设法将“update-database”应用于Azure数据库. 当我在本地尝试应用程序,但使用Azure SQL数据库,它的工作正常. 当我在线尝试应用程序,我可以使用测试控制器,但登录或注册链接给出以下异常: Server Error in '/' Application. The "WebSecurity.InitializeDatabaseConnection" method can be called only once. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The "WebSecurity.InitializeDatabaseConnection" method can be called only once. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [InvalidOperationException: The "WebSecurity.InitializeDatabaseConnection" method can be called only once.] WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership,DatabaseConnectionInfo connect,String userTableName,String userIdColumn,String userNameColumn,Boolean createTables) +123 WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect,Boolean autoCreateTables) +51 WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName,Boolean autoCreateTables) +52 MembershipTest2.Filters.SimpleMembershipInitializer..ctor() +193 你有什么想法来自哪里? 谢谢. 解决方法
您可以尝试将该调用封装到该方法中,以确保不再调用一次
if (!WebMatrix.WebData.WebSecurity.Initialized) { WebSecurity.InitializeDatabaseConnection(...); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何检测当前应用程序池是否在IIS7.5和Asp.Net 3.5中清理
- 如何搭建Nuget服务器
- asp.net-mvc-3 – 从Razor _Layout.cshml访问Session对象
- asp.net – SyndicationFeed:内容为CDATA?
- asp.net-mvc – 如何在Ajax窗体的asp.net mvc中提交下拉列表
- asp.net-mvc – @helper和Url.Action
- 数组 – 带有int数组参数的EF ExecuteSqlCommand
- asp.net-mvc – 为什么httphandler没有运行
- asp.net-mvc – 添加为视图的链接intellisense
- asp.net – linq中的switch语句
推荐文章
站长推荐
- azure – Request.Content.ReadAsMultipartAsync
- asp.net – Diffplex入门
- asp.net-mvc – 如何避免打开重定向漏洞并成功登
- asp.net – Simplemembership – 添加电子邮件字
- asp.net-mvc – asp.net mvc 4将表单从站点发送到
- ASP.NET MVC – MapRoute与routes.Add(和404s)
- asp.net-mvc-3 – 在MVC3 Controller操作中返回文
- asp.net-mvc-2 – 检测到一个有潜在危险的reques
- 如何实现ASP.NET Web应用程序的自动错误/崩溃报告
- 在ASP.NET Identity 2.0.0-beta1中禁用双因素身份
热点阅读