c# – 尝试加载应用程序时发生以下错误. – OwinStartupAttribute.FriendlyName值

c# – 尝试加载应用程序时发生以下错误. – OwinStartupAttribute.FriendlyName值,第1张

概述我想用AspNetRoles创建下拉列表.我用这个代码: Idnetity Conf: public class ApplicationRoleManager : RoleManager<IdentityRole>{ public ApplicationRoleManager(IRoleStore<IdentityRole, string> roleStore) : ba 我想用AspNetRoles创建下拉列表.我用这个代码:

IDnetity Conf:

public class ApplicationRoleManager : RoleManager<IDentityRole>{    public ApplicationRoleManager(IRoleStore<IDentityRole,string> roleStore)        : base(roleStore)    {    }    public static ApplicationRoleManager Create(IDentityFactoryOptions<ApplicationRoleManager> options,IOwinContext context)    {        return new ApplicationRoleManager(new RoleStore<IDentityRole>(context.Get<ApplicationDbContext>()));    }}

.

启动:

using System;using Microsoft.AspNet.IDentity;using Microsoft.AspNet.IDentity.Owin;using Microsoft.Owin;using Microsoft.Owin.Security.cookies;using Microsoft.Owin.Security.Google;using Owin;using IDentity_Work.Models;namespace IDentity_Work{    public partial class Startup    {        public voID ConfigureAuth(IAppBuilder app)        {            app.CreatePerOwinContext(ApplicationDbContext.Create);            app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);            app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create);            app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);            app.UsecookieAuthentication(new cookieAuthenticationoptions            {                AuthenticationType = DefaultAuthenticationTypes.Applicationcookie,LoginPath = new PathString("/Account/Login"),ProvIDer = new cookieAuthenticationProvIDer                {                      OnValIDateIDentity = SecurityStampValIDator.OnValIDateIDentity<ApplicationUserManager,ApplicationUser>(                        valIDateInterval: TimeSpan.FromMinutes(30),regenerateIDentity: (manager,user) => user.GenerateUserIDentityAsync(manager))                }            });            app.UseExternalSignIncookie(DefaultAuthenticationTypes.Externalcookie);            app.UseTwoFactorSignIncookie(DefaultAuthenticationTypes.TwoFactorcookie,TimeSpan.FromMinutes(5));    app.UseTwoFactorRememberbrowsercookie(DefaultAuthenticationTypes.TwoFactorRememberbrowsercookie);        }    }}

.
Web配置:

<appSettings><add key="webpages:Version" value="3.0.0.0" /><add key="webpages:Enabled" value="false" /><add key="ClIEntValIDationEnabled" value="true" /><add key="UnobtrusiveJavaScriptEnabled" value="true" /><add key="owin:AppStartup" value="IDentity_Work.IDentityConfig" />

控制器:

[AllowAnonymous]public ActionResult Register(){    VIEwBag.name = new SelectList(db.Roles,"RoleID","Rolename");    return VIEw();}

查看:

<div >    <label>نوع عضویت</label>    <div >        @HTML.DropDownList("name","--Select name--")    </div></div>

但是当我运行项目时显示这个错误:

The following errors occurred while attempting to load the app.
– The OwinStartupAttribute.FrIEndlyname value ” does not match the given value ‘IDentity_Work.IDentityConfig’ in Assembly ‘IDentity_Work,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null’.
– The given type or method ‘IDentity_Work.IDentityConfig’ was not found. Try specifying the Assembly.
To disable OWIN startup discovery,add the appSetting owin:automaticAppStartup with a value of “false” in your web.config.
To specify the OWIN startup Assembly,Class,or Method,add the appSetting owin:AppStartup with the fully qualifIEd startup class or configuration method name in your web.config.

.有什么问题 ?

编辑

解决方法 像错误消息解释一样

The OwinStartupAttribute.FrIEndlyname value ” does not match the
given value ‘IDentity_Work.IDentityConfig’

按照错误消息的说明进行 *** 作

The given type or method ‘IDentity_Work.IDentityConfig’ was not found.
Try specifying the Assembly. To disable OWIN startup discovery,add
the appSetting owin:automaticAppStartup with a value of “false” in
your web.config. To specify the OWIN startup Assembly,or
Method,add the appSetting owin:AppStartup with the fully qualifIEd
startup class or configuration method name in your web.config.

首先您应该检查Startup.cs以查看它是否具有对该类的正确引用

[assembly: OwinStartup(typeof(IDentity_Work.Startup))]

如果是,那么你需要删除web.config中的owin:AppStartup(如果它存在)并且没有引用正确的类

<add key="owin:automaticAppStartup" value="true" />

否则,您可以更新web.config以让owin使用

<add key="owin:automaticAppStartup" value="false" /><add key="owin:AppStartup" value="IDentity_Work.Startup" />
总结

以上是内存溢出为你收集整理的c# – 尝试加载应用程序时发生以下错误. – OwinStartupAttribute.FriendlyName值全部内容,希望文章能够帮你解决c# – 尝试加载应用程序时发生以下错误. – OwinStartupAttribute.FriendlyName值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1220199.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存