IE11 / IE10兼容性视图 - 导航错误

时间:2014-11-20 09:54:15

标签: c# html5 twitter-bootstrap internet-explorer authentication

我有一个刚刚使用twitter bootstrap 3网站和HTML5设计的网站,但我在IE11和IE10兼容性方面存在问题,因为当用户登录时,他们会经历以下过程:

  1. 输入用户名并点击“继续/输入密钥”>转到密码页面
  2. 输入密码并点击“登录/输入密钥”>转到帐户摘要页面
  3. 问题是,一旦密码验证并且正确,就会重新显示“输入用户名”页面用户实际登录时显示安全主菜单

    我试图对它进行去除错误,但没有标记任何内容,使用F12也标记没有错误,除了信息之一(HTML1300),但谷歌搜索时,没有答案。

    有没有办法强制网站使用正确的页面(提供密码正确)或我可以采取的任何措施来阻止这种情况发生,因为有些用户在使用我的网站时会记录此信息。

    如上所述,这只是IE11和IE10兼容模式的问题。使用IE10(通常)和其他浏览器都可以。

    我的观点代码是:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
    <%@ Import Namespace="AJBG.CMS2.Sippcentre.AppCode.Helpers" %>
    
    <%
        var Clientdata = (typeof(AJBG.CMS2.Sippcentre.AppCode.Entities.LogIn.ClientAdditionalActions) == AJBG.CMS2.Sippcentre.AppCode.Wrappers.Session.Process.Data.GetType()) ? (AJBG.CMS2.Sippcentre.AppCode.Entities.LogIn.ClientAdditionalActions)AJBG.CMS2.Sippcentre.AppCode.Wrappers.Session.Process.Data : null;
    
        var data = (typeof(AJBG.Web.Services.Messages.User.Authentication.Status.Response) == AJBG.CMS2.Sippcentre.AppCode.Wrappers.Session.Process.Data.GetType()) ? (AJBG.Web.Services.Messages.User.Authentication.Status.Response)AJBG.CMS2.Sippcentre.AppCode.Wrappers.Session.Process.Data : null;
    
        var cmsText = ((AJBG.CMS2.Sippcentre.AppCode.Translators.LogIn.ChallengeResponse)Model.Data);
        var username = Clientdata != null ? Clientdata.Username : data.Username;
        AJBG.CMS2.Sippcentre.AppCode.Functions.Template content = new AJBG.CMS2.Sippcentre.AppCode.Functions.Template()
            {
                HtmlTemplate = cmsText.Intro_Text
            };
    
        content.Nvc.Add("[!Password_TextBox]", Html.Password("Password_TextBox", "", new { @class = "form-control", maxlength = 30 }).ToHtmlString());
        content.Nvc.Add("[!Password_TextBox_xs]", Html.Password("Password_TextBox_xs", "", new { @class = "form-control", maxlength = 30 }).ToHtmlString());
        content.Nvc.Add("[!ErrorMessage]", AJBG.CMS2.Sippcentre.AppCode.Website.CStr(Html.ValidationMessage("LogInFailure")));
        content.Nvc.Add("[!SubmitButton]", Html.ButtonBootStrap("submit", "btn btn-default", "Login", "Login", "glyphicon glyphicon-lock", "DisableButton(this);").ToHtmlString());
        content.Nvc.Add("[!UserName]", username);
    %>
    
    <%using (Html.BeginForm(null, null, FormMethod.Post, new { role = "form", @class = "form-horizontal", name = "ChallengeForm", id = "ChallengeForm" }))
    
    { %>
    <% 
          if (username.Contains("SCA"))
          {
              Response.Write(cmsText.Adviser_top_text);
          }
          else if (username.Contains("SCC"))
          {
              Response.Write(cmsText.Client_top_text);
          }
    %>
    
    <%= content.ToString() %>
    
    <% 
          if (username.Contains("SCA"))
          {
              Response.Write(cmsText.Adviser_bottom_text);
          }
          else if (username.Contains("SCC"))
          {
              Response.Write(cmsText.Client_bottom_text);
          }
    
    } %>
    
    <script language="javascript" type="text/javascript">
        function DisableButton(obj)
        {
            obj.disabled = true;
            <% if (Request.Browser.Browser == "InternetExplorer" || Request.Browser.Browser == "IE")
            { %>
            if (document.documentMode < 9 || "<%=Request.Browser.Version.ToString()%>" == "7.0")
            {
                ChallengeForm.submit();
            }
            <%}
            else
            {%>
                ChallengeForm.submit();
            <%}%>
            return true;
        }
    
        if ($(".field-validation-error").is(":visible"))
        {
            $("#myModal").remove();
            $(".modal-backdrop").remove();
        }
    
        if ($("#myModal").is(":visible") == false)
        {
            SetFocus("Password_TextBox");
        }
    
        $("#Close").on("click", function ()
        {
            SetFocus("Password_TextBox");
        })
    </script>
    

    背后的代码是:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using AJBG.Web.Services.Entities.User;
    
    namespace AJBG.CMS2.Sippcentre.AppCode.ProcessFlow.OriginalLogIn
    {
        public class InitialChallenge : ProcessFlow.Base
        {
    
            #region Private Data vars / objects
    
            private Web.Services.Messages.User.Authentication.Status.Response _model = null;
            private String _password = String.Empty;
            private String _userName = String.Empty;
    
            #endregion
    
            public InitialChallenge(String controller) : base(controller) { }
    
            public void Setup(ModelStateDictionary modelState)
            {
            }
    
            public void Form(ModelStateDictionary modelState)
            {
                _model      = (Web.Services.Messages.User.Authentication.Status.Response)Wrappers.Session.Process.Data;        
                _password   = HttpContext.Current.Request["Password_TextBox"].ToString();
                _password = String.IsNullOrEmpty(_password) ? HttpContext.Current.Request["Password_TextBox_xs"].ToString() : _password;
                _userName = _model.Username;
    
                if(Validators.Security.PasswordChallenge(_password,"LoginFailure",modelState))
                {
                    String migrateErrormessage = String.Empty;
                    String credentialsError = String.Empty;
    
                    #region Credentials Error Check
    
                    switch (_model.Type)
                    {
                        case Web.Services.Messages.Enums.AccountType.OldAdviser:
                            credentialsError = PasswordAdviserCheckBeforeMigration();
                            break;
                        case Web.Services.Messages.Enums.AccountType.OldClient:
                            credentialsError =PasswordClientCheckBeforeMigration();
                            break;
                        default:
                            break;
                    }
    
                    #endregion
    
                    if (credentialsError.Equals(String.Empty))
                    {
                        if ((_model.Type == Web.Services.Messages.Enums.AccountType.Adviser) || (_model.Type == Web.Services.Messages.Enums.AccountType.OldAdviser))
                        {
                            #region Adviser Log In
    
                            if (MigrateAdviserAccount(_model.Type, out migrateErrormessage))
                            {
                                //var result = new Sippcentre.AccountAdministrationWebService.Adviser.AdviserClient().OriginalLogIn
                                //                 (
                                //                       new Web.Services.Messages.Adviser.Authentication.OriginalLogIn.Request
                                //                       {
                                //                           LogInAttemptIdentifier = new Guid(),
                                //                           Username = _model.Username,
                                //                           Password = _password,
                                //                           Source = Web.Services.Messages.Enums.MessageSource.Sippcentre
                                //                       }
                                //                 );
    
                                // *********** ENTITY WRAPPER CALL
                                var result = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin.OriginalLogIn(new Guid(), _model.Username, _password, _model.UserIdentifier);
    
                                if (result.Details == null)
                                {
                                    //Added to account for IFAs Who have just Registered but their details have not quite been populated.
                                    if (result.ResponseCode == Web.Services.Messages.Enums.LoginResponseCode.IFA_FIRM_PopulationError)
                                    {
    
                                        AppCode.Wrappers.Session.User.ClearUserData();
                                        Wrappers.Session.Process.StartExiting();
                                        Wrappers.Session.Process.Step = Steps.FirstOrDefault(d => d.Situation == "PopulationError");
                                    }
                                    //will redirect you to account suspended page if password is locked.
                                    if (!UserStatusOK()) return;
    
                                    if (Website.MaskError)
                                    {
                                        modelState.AddModelError("LoginFailure", ErrorMessages.Security.PasswordIncorrect);
                                    }
                                    else
                                    {
                                        modelState.AddModelError("LoginFailure", ErrorMessages.Security.PasswordIncorrect);
                                    }
    
                                    modelState.AddModelError("Password_TextBox", "");
                                    return;
                                }
    
                                ProcessAdviserStep(result);
                            }
                            else
                            {
                                modelState.AddModelError("LoginFailure", migrateErrormessage);
                            }
    
    
                            #endregion
                        }
                        else if ((_model.Type == Web.Services.Messages.Enums.AccountType.Client) || (_model.Type == Web.Services.Messages.Enums.AccountType.OldClient))
                        {
                            #region Client Log In 
    
                            if (MigrateClientAccount(_model.Type, out migrateErrormessage))
                            {
    
                                //var result = new Sippcentre.AccountAdministrationWebService.Client.ClientClient().OriginalLogIn
                                //(
                                //  new Web.Services.Messages.Client.Authentication.OriginalLogIn.Request
                                //     {
                                //         LogInAttemptIdentifier = _model.LogInAttemptIdentifier,
                                //         Password = _password,
                                //         Username = _model.Username,
                                //         Source = Web.Services.Messages.Enums.MessageSource.Sippcentre
                                //     }
                                // );
    
                                // *********** ENTITY WRAPPER CALL
                                var result = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin.ClientLogIn(_model.LogInAttemptIdentifier, _model.Username, _password);
    
                                if (result.Details == null)
                                {
                                    //will redirect you to account suspended page if password is locked.
                                    if (!UserStatusOK()) return;
    
                                    modelState.AddModelError("LogInFailure", String.Format(ErrorMessages.Security.AdviserLogInFailure, Steps.FirstOrDefault(d => d.Situation == "Entry").Url));
                                    modelState.AddModelError("Password_TextBox", "");
                                    return;
                                }
    
                                ProcesClientStep(result);
                            }
                            else
                            {
                                modelState.AddModelError("LoginFailure", migrateErrormessage);
                                modelState.AddModelError("Password_TextBox", "");
                            }
    
                            #endregion
                        }
                        else { }
                    }
                    else  
                    {
                        modelState.AddModelError("LoginFailure", credentialsError);
                        modelState.AddModelError("Password_TextBox", "");
                    }
                }
            }
    
            #region Exit
    
            public override Boolean Exit(ModelStateDictionary modelState, ViewDataDictionary viewData)
            {
                return false;
            }
    
            #endregion
    
            #region Migration Methods
    
            private Boolean MigrateAdviserAccount(Web.Services.Messages.Enums.AccountType account, out String error)
            {
                error = String.Empty;
    
                if (account == Web.Services.Messages.Enums.AccountType.OldAdviser)
                {
                   // var clientAuthentication = new Sippcentre.AccountAdministrationWebService.Client.ClientClient();
    
                   // var result = new AccountAdministrationWebService.General.GeneralClient().MigrateAccount(
    
                   //     new Web.Services.Messages.User.Migration.TransferAccount.Request
                   //     {
    
                   //         Password = _password,
                   //         UserIdentifier = _model.UserIdentifier,
                   //         Username = _model.Username,
                   //         Source = Web.Services.Messages.Enums.MessageSource.Sippcentre,
                   //         PasswordExpired = (Boolean) (_model.Status ==  Web.Services.Messages.Enums.AccountStatus.ExpiredPassword) 
                   //     }
                   //);
    
                    // *********** ENTITY WRAPPER CALL
                    var result = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin.MigrateAccount(_password, 
                        _model.UserIdentifier, 
                        _model.Username, 
                        (Boolean)(_model.Status == Web.Services.Messages.Enums.AccountStatus.ExpiredPassword), 
                        _model.UserIdentifier, _model.LogInAttemptIdentifier);
    
                    error = result.GetErrorMessages();
                    return result.Success;
                }
    
    
                return (account == Web.Services.Messages.Enums.AccountType.Adviser) ? true : false;
            }
    
            private Boolean MigrateClientAccount(Web.Services.Messages.Enums.AccountType account, out String error)
            {
                error = String.Empty;
                if (account == Web.Services.Messages.Enums.AccountType.OldClient)
                {
                   // var clientAuthentication = new Sippcentre.AccountAdministrationWebService.Client.ClientClient();
    
                   // var result = new AccountAdministrationWebService.General.GeneralClient().MigrateAccount(
    
                   //     new Web.Services.Messages.User.Migration.TransferAccount.Request
                   //    {
                   //        Password         = _password,
                   //        UserIdentifier   = _model.UserIdentifier,
                   //        Username         = _model.Username,
                   //        Source           = Web.Services.Messages.Enums.MessageSource.Sippcentre,
                   //        PasswordExpired  = (Boolean)(_model.Status == Web.Services.Messages.Enums.AccountStatus.ExpiredPassword) 
                   //    }
                   //);
    
                    // *********** ENTITY WRAPPER CALL
                    var result = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin.MigrateAccount(_password, 
                                _model.UserIdentifier, 
                                _model.Username, 
                                (Boolean)(_model.Status == Web.Services.Messages.Enums.AccountStatus.ExpiredPassword), 
                                _model.UserIdentifier,
                                _model.LogInAttemptIdentifier); 
    
                    error = result.GetErrorMessages();
                    return result.Success;
                }
    
                return (account == Web.Services.Messages.Enums.AccountType.Client) ? true : false;
            }
    
            #endregion
    
            #region Process Step Methods
    
            private void ProcessAdviserStep(AJBG.Web.Services.Messages.Adviser.Authentication.OriginalLogIn.Response result)
            {
                AppCode.Wrappers.Session.User.ClearUserData();
                AppCode.Wrappers.Session.User.Adviser = result.Details;
    
                switch (_model.Status)
                {
    
                    case Web.Services.Messages.Enums.AccountStatus.ExpiredSecurityQuestion:
                    case Web.Services.Messages.Enums.AccountStatus.Active:
                        Wrappers.Session.Process.StartExiting();
    
                        if (_model.RedirectTo != null && _model.RedirectTo.Length > 0)
                        {
                            var url = AppCode.Functions.Functions.ConvertToVirtualPath(_model.RedirectTo.Split('?')[0]);
                            if (url.StartsWith(AppCode.Wrappers.Application.Area.AdviserExclusive) || !url.StartsWith(AppCode.Wrappers.Application.Area.ClientExclusive))
                            {
                                Wrappers.Session.Process.ForcedRedirect = AppCode.Functions.Functions.ConvertToVirtualPath(_model.RedirectTo.Split('?')[0]) + _model.RedirectTo.Replace(_model.RedirectTo.Split('?')[0], "").Replace("%amp;", "&");
                            }
                        }
                        Wrappers.Session.Process.Step = Steps.FirstOrDefault(d => d.Situation == "ExitAdviser");
                        break;
                    case Web.Services.Messages.Enums.AccountStatus.ExpiredPassword:
                        Wrappers.Session.Process.Data = new Entities.LogIn.AdviserAdditionalActions
                        {
                            LoginAttemptIdentifier = _model.LogInAttemptIdentifier,
                            Details = result.Details,
                            Status = _model.Status,
                            Username = _model.Username,
                            UserIdentifier = _model.UserIdentifier,
    
                        };
                        Wrappers.Session.Process.Step = Steps.FirstOrDefault(d => d.Situation == "ExpiredPassword");
                        break;
                    default:
                        break;
                }
    
            }
    
            private void ProcesClientStep(AJBG.Web.Services.Messages.Client.Authentication.OriginalLogIn.Response result)
            {
                AppCode.Wrappers.Session.User.ClearUserData();
                AppCode.Wrappers.Session.User.Client = result.Details;
    
                //work out if this is a junior client//
                Boolean isJunior = false;
                if (result.Details.HasIsa)
                {
                    if (result.Details.Isa.IsJunior) { isJunior = true; }
                } 
                if (result.Details.HasSipp)
                {
                    if (result.Details.Sipp.IsJunior) { isJunior = true; }
                }
    
                switch (_model.Status)
                {
                    case Web.Services.Messages.Enums.AccountStatus.ExpiredSecurityQuestion:
                    case Web.Services.Messages.Enums.AccountStatus.Active:
                        Wrappers.Session.Process.StartExiting();
    
                        if ((_model.RedirectTo != null) && (_model.RedirectTo.Length > 0))
                        {
                            var url = AppCode.Functions.Functions.ConvertToVirtualPath(_model.RedirectTo.Split('?')[0]);
                            if (!url.StartsWith(AppCode.Wrappers.Application.Area.AdviserExclusive) || url.StartsWith(AppCode.Wrappers.Application.Area.ClientExclusive))
                            {
                                Wrappers.Session.Process.ForcedRedirect = AppCode.Functions.Functions.ConvertToVirtualPath(_model.RedirectTo.Split('?')[0]) + _model.RedirectTo.Replace(_model.RedirectTo.Split('?')[0], "").Replace("%amp;", "&");
                            }
                        }
    
    
                        if (isJunior)
                        {
                            Wrappers.Session.Process.Step = Steps.FirstOrDefault(d => d.Situation == "ExitJunior");
                        }
                        else
                        {
                            Wrappers.Session.Process.Step = Steps.FirstOrDefault(d => d.Situation == "ExitClient");
                        }
                        break;
                    case Web.Services.Messages.Enums.AccountStatus.ExpiredPassword:
                        Wrappers.Session.Process.Data = new Entities.LogIn.ClientAdditionalActions
                        {
                            LoginAttemptIdentifier = _model.LogInAttemptIdentifier,
                            Details = result.Details,
                            Status = _model.Status,
                            Username = _model.Username,
                            UserIdentifier = _model.UserIdentifier
    
                        };
                        Wrappers.Session.Process.Step = Steps.FirstOrDefault(d => d.Situation == "ExpiredPassword");
                        break;
                    default:
                        break;
                }
            }
    
            #endregion
    
            #region PasswordCheckMigration
    
            public String PasswordAdviserCheckBeforeMigration()
            {
                //Sippcentre.AccountAdministrationWebService.Adviser.AdviserClient adviserClient = new AccountAdministrationWebService.Adviser.AdviserClient();
    
                //var result = adviserClient.OldLogIn(new Web.Services.Messages.Adviser.Authentication.OldLogIn.Request
                //{
                //    LogInAttemptIdentifier = _model.LogInAttemptIdentifier,
                //    Password = _password,
                //    Username = _userName,
                //    Source = Web.Services.Messages.Enums.MessageSource.Sippcentre
                //});
    
                // *********** ENTITY WRAPPER CALL
                var result = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin.OldLogin(_model.LogInAttemptIdentifier, _userName, _password);
    
                //adviserClient.Close();
    
                if (result.Success)
                {
                    if (result.ErrorMessages.Count > 0)
                    {
                        if (Website.MaskError)
                        {
                            if (result.ResponseCode == Web.Services.Messages.Enums.LoginResponseCode.CredentialsFailed)
                                return ErrorMessages.Security.PasswordIncorrect;
                            else
                                return Log.MaskErrors(result.ResponseCode);
                        }
                        else
                        {
                            return result.GetErrorMessages();
                        }
                    }
                }
    
                return String.Empty;
            }
    
            public String PasswordClientCheckBeforeMigration()
            {
    
                    //Sippcentre.AccountAdministrationWebService.Client.ClientClient clientClient = new Sippcentre.AccountAdministrationWebService.Client.ClientClient();
                    //var result = clientClient.OldLogIn(new Web.Services.Messages.Client.Authentication.OldLogIn.Request
                    //{
                    //    LogInAttemptIdentifier = _model.LogInAttemptIdentifier,
                    //    Password = _password,
                    //    Username = _userName,
                    //    Source = Web.Services.Messages.Enums.MessageSource.Sippcentre
                    //});
                    //clientClient.Close();
    
                    // *********** ENTITY WRAPPER CALL
                    //var result = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin._OldLogin(_model.LogInAttemptIdentifier, _userName, _password);
    
                    // The login process is no different in case of old users . The users will still be avalable in WebUser table 
                    var result = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin.ClientLogIn(_model.LogInAttemptIdentifier, _userName, _password);
    
                    if (result.Success)  {
                     if (result.ErrorMessages.Count > 0)
                     {
                        if (Website.MaskError)
                        {
                            if (result.ResponseCode == Web.Services.Messages.Enums.LoginResponseCode.CredentialsFailed)
                                return ErrorMessages.Security.PasswordIncorrect;
                            else
                                return Log.MaskErrors(result.ResponseCode);
                        }
                        else
                        {
                            return result.GetErrorMessages();
                        }
                    }
                   }
    
                return String.Empty;
            }
    
    
            #endregion
    
            #region check Status 
    
            private Boolean UserStatusOK()
            {
                Boolean statusOK = true;
    
                //var accountStatus = new AccountAdministrationWebService.General.GeneralClient().CheckUserStatus(new Web.Services.Messages.User.Authentication.Status.Request
                //{
                //    Username = _userName,
                //    RequestByIdentifier = _userName,
                //    Source = Web.Services.Messages.Enums.MessageSource.Sippcentre
                //});
    
                // *********** ENTITY WRAPPER CALL
                var accountStatus = AJBG.CMS2.Sippcentre.AppCode.EntityWrappers.AccountAdmin.CheckUserStatus(_userName, _userName);
    
                if (accountStatus.Status == Web.Services.Messages.Enums.AccountStatus.Suspended)
                {
                    Wrappers.Session.Process.Data = null;
                    Wrappers.Session.Process.Step = Steps.First(d => d.Situation == "ResponseSuspended");
                    statusOK = false;
                }
    
                return statusOK;
            }
    
            #endregion
    
        }
    }
    

1 个答案:

答案 0 :(得分:1)

经过调查,这是因为IE11现在以Mozilla的形式回归,因此它没有打到我的代码。将Majorverion > 10添加到以下行已修复了我的问题

if (Request.Browser.Browser == "InternetExplorer" || Request.Browser.Browser == "IE" || Majorverion > 10

希望这有助于其他人