System.Web.Security.SqlMembershipProvider”要求一个与架构版本“1”兼容的数据库架构。

本文详细介绍了使用SQL脚本解决ASP.NET从本地数据库迁移至服务器过程中遇到的SchemaVersions初始化错误,包括如何正确填充aspnet_SchemaVersions表以避免Asp.net配置错误,以及后续登录验证问题的解决思路。

通过sql脚本生成的方式,将本地数据库迁移到服务器上,本来只是选择了表,其他都没选,发生了没有存储过程的错误,然后把存储过程create一次,生成成功,发生了如题所示的错误。Asp.net配置也显示这个错误。然后百度了一下,有两个大方向的答案。

一个是本文接下来的内容,一个是通过asp.net reg_sql,之前还写过配置的方法。试了下reg_sql,其实想到了不能用,然后果然不能用,报错如下,应该是没有权限之类的错误。


然后在把找到的文章中的sql代码粘到了查询窗口,执行。结果成功,并且asp.net配置再进入,已经成功。但是程序有Authorize部分登录仍然不成功,报同样的错误。


但是,之后VS因为F10/F11一用就重启的问题,重启了一次之后,再运行就可以了,所以猜测是程序那个地方反映比较慢,这个解决方案是可行的。

这是我看到的博客来源http://www.cnblogs.com/webfpc/archive/2010/05/09/1731351.html

原博客的报错一样,但是他是迁移到自己数据库出的错误,而我迁移自己数据库用的asp.net reg_sql,没有问题,迁移服务器出的问题,解决方案相同,但是原理不明。

以下是起作用的部分:

解决方案:

在自己的数据库里为aspnet_SchemaVersions表初始化数据就好了。

 


/*Insert aspnet_SchemaVersions*/
INSERT INTO [dbo].[aspnet_SchemaVersions]
           ([Feature]
           ,[CompatibleSchemaVersion]
           ,[IsCurrentVersion])
     VALUES
          ('common','1',1)

INSERT INTO [dbo].[aspnet_SchemaVersions]
           ([Feature]
           ,[CompatibleSchemaVersion]
           ,[IsCurrentVersion])
     VALUES
          ('health monitoring','1', 1);

INSERT INTO [dbo].[aspnet_SchemaVersions]
           ([Feature]
           ,[CompatibleSchemaVersion]
           ,[IsCurrentVersion])
     VALUES
          ('membership', '1', 1)

 
INSERT INTO [dbo].[aspnet_SchemaVersions]
           ([Feature]
           ,[CompatibleSchemaVersion]
           ,[IsCurrentVersion])
     VALUES
          ('personalization','1', 1)

 
INSERT INTO [dbo].[aspnet_SchemaVersions]
           ([Feature]
           ,[CompatibleSchemaVersion]
           ,[IsCurrentVersion])
     VALUES
          ('profile','1', 1)


INSERT INTO [dbo].[aspnet_SchemaVersions]
           ([Feature]
           ,[CompatibleSchemaVersion]
           ,[IsCurrentVersion])
     VALUES
          ('role manager','1', 1)



以下是网站目前的webconfig文件 改怎么修改 <?xml version="1.0" encoding="UTF-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=152368 --> <configuration> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> <appSettings configProtectionProvider="RsaProtectedConfigurationProvider"> <EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#"> <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" /> <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#"> <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /> <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"> <KeyName>Rsa Key</KeyName> </KeyInfo> <CipherData> <CipherValue>G+DsdRtaxe0KW7q0OXT2A2TaUpeiZtkWsxvozK3E5gCFiP2u +nz7kdqzzC9be6ODsipCEoLTOKove4o1LZ34Vpgf7xUBBhZD15Zq8DdazCyYHnrn3TO5AMzjQ6I5f7NYspz69dw1kx6fI6yLHc8nwvXkxLq0aI1VZtTcc 525An4T7e6N4KOuNTnDQCUKO+EJoJh4W7tISZ37ygGQGzSH747CMGXWx9ZsVcNz+Jtc+ot +cGt9Gm/A6+b2NeQd3IgRe3qooXb6V0Jdi/2wONuPJ1FVWXfsnQRFD0imJxzFk86ChKKWK1c0SWMsrqZhUi0w4aTD26T +QL77Bg4qQsRGsQ==</CipherValue> </CipherData> </EncryptedKey> </KeyInfo> <CipherData> <CipherValue>O+M +/jfmUYbauWytN4pGYc55ElmhWj8SMkZUJmmwJ9Zzpm46To5tsbKWamxHvdqemCvIa9zUITppIFTuDdeejMVHHpPsXHUUkTk602Z3Uph94+nBSXVn0Agx DhHzgCEmRrv/1nFfffr6z6YleY1oSxjFDbyghteTiG5ksdw9bsbyLByvE6Kzx6D9lOwhN1U6m5nltBwFeYGJ +HKV5ayk3yKc9NkRf7nhzYzscKf9T8N74iNLNUddMiKojFSj4KZl+exXDj0vWG5emWBxwUStlx8ebXsxILBvHZUUE8xVmNWnue6MfGu369mB +ilqWmQivTsmPQIiW228rDPQtAfH74zAuQUftU1LlpcMeGQnCGc999FZQaBsScOwub0RUu2GB4OD562EzahxNGgzlRvt4ZiRcPDi32AVlHR5AKWn/ZpZi fZdQOUzvW/e8lrOSrJc0Yzl/piERRf4qmyYglnrC/U6+H8oJ0mcD6yfPtdoMLfLcuQpuMuvpaPrSbOPxQaPxfeq+eFc+ +q0GpTj0cFndrgdK0o7a0NGjKyrcuYIKgOG6nnL5E9IPUoVZp/yycJLSVb0QybgnKn0IBRVZZHt3p4wMMS9VyNlsLnl+DD7TaU=</CipherValue> </CipherData> </EncryptedData> </appSettings> <system.web> <httpRuntime enableVersionHeader="false" requestValidationMode="2.0" executionTimeout="500" maxRequestLength="409600" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" /> <customErrors allowNestedErrors="true" defaultRedirect="http://www.huadonghospital.com/index.html" mode="On" /> <compilation debug="false" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> <membership> <providers> <clear /> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <profile> <providers> <clear /> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /> </providers> </profile> <roleManager enabled="false"> <providers> <clear /> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> </providers> </roleManager> <pages validateRequest="false"> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages" /> </namespaces> </pages> <httpCookies httpOnlyCookies="true" /> <globalization requestEncoding="GB2312" responseEncoding="GB2312" uiCulture="zh-CN" culture="zh-CN" fileEncoding="GB2312" /> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <staticContent> <clientCache cacheControlMode="DisableCache" /> </staticContent> <defaultDocument> <files> <clear /> <add value="index.html" /> </files> </defaultDocument> <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> <add name="X-Frame-Options" value="SAMEORIGIN" /> </customHeaders> </httpProtocol> <httpErrors errorMode="DetailedLocalOnly"> <remove statusCode="404" /> <error statusCode="404" path="/index.html" responseMode="ExecuteURL" /> </httpErrors> <security> <requestFiltering> <verbs> <add verb="OPTIONS" allowed="false" /> <add verb="TRACE" allowed="false" /> </verbs> </requestFiltering> </security> <rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
最新发布
11-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值