私はAspNetRoles
でドロップダウンリストを作成したいと思います。アプリケーションの読み込み中に次のエラーが発生しました。 - OwinStartupAttribute.FriendlyNameの値
Idnetityコンファレンス:
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>()));
}
}
私はこのコードを使用します。
STARTUP:
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);
}
}
}
。 ウェブ設定:
<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 class="form-group">
<label>نوع عضویت</label>
<div class="col-md-10">
@Html.DropDownList("name", "--Select Name--")
</div>
</div>
しかし、私は、プロジェクトを実行したときに私は、このエラーを示しています。
アプリの読み込み中に次のエラーが発生しました。 - OwinStartupAttribute.FriendlyName値 'が' Identity_Work、Version = 1.0.0.0、Culture = neutral、PublicKeyToken = null 'の' Identity_Work.IdentityConfig 'と一致しません。 - 指定されたタイプまたはメソッド 'Identity_Work.IdentityConfig'が見つかりませんでした。アセンブリを指定してみてください。 OWINの起動検出を無効にするには、web.configに「false」の値を持つappSetting owin:AutomaticAppStartupを追加します。 OWINの起動アセンブリ、クラス、またはメソッドを指定するには、webSetで完全修飾スタートアップクラスまたは構成メソッド名を使用してappSetting owin:AppStartupを追加します。
。どうしたの ?
編集
は、完全な起動ファイルを表示します。 webconfig – Nkosi
更新に関する質問の関連する設定 – Kianoush