0

MVC 4.0 プロジェクトに取り組んでいます。アクション メソッドの承認に基づいてロールを実行するために、カスタム承認属性ソリューションのソリューションを既に実装しています。しかし、このソリューションは審査で受け入れられず、承認とルーティングを処理するサービスを作成するように言われました。

4

1 に答える 1

0
On the gloabl.asas.cs file you can add the below event and then do whatever you want to do

    protected void Application_AuthenticateRequest(Object sender, EventArgs e)
                {
                    if (Features.UserValidationEnabled)
                    {
          if (!safeExtension && Security.CurrentUser.IsInRole("User"))
                            {
                                if (!AccountManager.CheckFlag(Security.CurrentUser, AccountManager.Capabilities.IsValidated))
                                {
                                    if (!HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.StartsWith("~/Account", StringComparison.OrdinalIgnoreCase))
                                    {
                                        Response.Redirect("~/Account/Validate");
                                    }
                                }
        }
        }}
于 2012-09-17T14:08:24.367 に答える