asp.net-mvc – 我的web.config中没有角色管理器部分定义
发布时间:2020-12-16 06:48:45 所属栏目:asp.Net 来源:网络整理
导读:我在VS 2010 express上创建了一个新的mvc4项目.现在我想向db添加角色.我使用包管理器控制台运行update- database命令来插入角色,它给我以下错误 PM Update-Database -verboseUsing StartUp project 'eManager.Web'.Using NuGet project 'eManager.Web'.Speci
我在VS 2010 express上创建了一个新的mvc4项目.现在我想向db添加角色.我使用包管理器控制台运行update-
database命令来插入角色,它给我以下错误
PM> Update-Database -verbose Using StartUp project 'eManager.Web'. Using NuGet project 'eManager.Web'. Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Target database is: 'eManager.Web' (DataSource: .SQLEXPRESS,Provider: System.Data.SqlClient,Origin: Configuration). No pending code-based migrations. Running Seed method. System.Configuration.Provider.ProviderException: The Role Manager feature has not been enabled. at System.Web.Security.Roles.EnsureEnabled() at System.Web.Security.Roles.RoleExists(String roleName) at eManager.Web.Migrations.Configuration.Seed(DepartmentDb context) in C:UsersAdministratorDesktopeManagereManager.WebMigrationsConfiguration.cs:line 26 at System.Data.Entity.Migrations.DbMigrationsConfiguration`1.OnSeed(DbContext context) at System.Data.Entity.Migrations.DbMigrator.SeedDatabase() at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.SeedDatabase() at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations,String targetMigrationId,String lastMigrationId) at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations,String lastMigrationId) at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration) at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore() at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() 尚未启用角色管理器功能. 我需要启用角色管理器,但我找不到web.config中的部分 以下是web.config文件 <?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=169433 --> <configuration> <configSections> <!-- For more information on Entity Framework configuration,visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version=4.4.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=.SQLEXPRESS;Initial Catalog=eManager.Web;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|eManager.mdf " providerName="System.Data.SqlClient" /> </connectionStrings> <appSettings> <!--<add key="enableSimpleMembership" value="true" />--> <add key="webpages:Version" value="2.0.0.0" /> <add key="webpages:Enabled" value="false" /> <add key="PreserveLoginUrl" value="true" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <compilation debug="true" targetFramework="4.0" /> <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" /> </authentication> <pages> <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.Optimization" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages" /> </namespaces> </pages> <compilation debug="true" targetFramework="4.5"> <assemblies> <add assembly="WebMatrix.Data,Version=2.0.0.0,PublicKeyToken=31bf3856ad364e35"/> <add assembly="WebMatrix.WebData,PublicKeyToken=31bf3856ad364e35"/> </assemblies> </compilation> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true" /> <handlers> <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,bitness64" responseBufferLimit="0" /> <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework" /> </entityFramework> </configuration> 解决方法
默认情况下该部分不存在,但您可以添加它.
把它放在< system.web>中 例如 <system.web> <roleManager defaultProvider="CustomRoleProvider" > <providers> <clear /> <add name="CustomRoleProvider" type="MyNamespace.CustomRoleProvider" /> </providers> </roleManager> <compilation debug="true" targetFramework="4.0" /> .... (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 将SignalR与现有授权集成
- 如何将文件从ASP.NET上载到另一个Web应用程序
- asp.net-mvc – ASP.NET MVC是否为区域创建默认路由
- asp.net-mvc – 忽略viewstart在asp.net mvc razor视图?
- ASP.NET Core RC2配置自定义AppSettings
- 在WinForms中验证用户(与ASP.Net无关)
- asp.net-mvc – 如何在ASP.NET MVC4中使用具有唯一标识符UR
- .NET Web应用中为什么要使用async/await异步编程
- asp.net-mvc-3 – 在MVC Razor View中使用If语句
- 想要像asp.net或stackoverflow那样选择标签吗?
推荐文章
站长推荐
- asp.net – ‘InitializeCulture’不是其成员
- asp.net – 生成本地资源后缺少服务器标签
- asp.net – 在将其上传到服务器之前,在客户端进行
- asp.net – 如何确保使用后无法恢复上传的文件内
- asp.net – 无法加载类型’site._Default'[已
- asp.net-mvc – IIS Express会自动禁用我的项目的
- 在ASP.NET捆绑和缩小中将样式的URL转换为CDN URL
- 深入理解ASP.NET MVC(目录)
- asp.net – 通过CSS重置HTML元素的高度
- asp.net-mvc-3 – 使用bootstrap,Asp.net Mvc 3和
热点阅读