私はログインとログアウト機能を実装しています。私は.NET MVCとangularJSを使用しています。私がHTTPSを入れるまで、すべてが機能していました。https導入後にng-clickが動作しない
これは、ログアウトのための私のangularJSコードです:
function getCareersView(myPath, myView) {
//var path = $window.location.pathname;
var pathParts = myPath.split('/');
var result = '/';
for (var i = 0; i < pathParts.length; i++) {
if (pathParts[i] !== 'Careers' && pathParts[i] !== '') {
result += pathParts[i];
result += '/';
};
if (pathParts[i] === 'Careers') {
result += pathParts[i];
break;
};
};
result += myView;
return result;
};
var mainModule = angular.module('main', ['ngAnimate', 'ui.bootstrap']);
mainModule.controller('mainController', function ($http, $scope, $location, $window) {
$scope.currentUserName = $window.sessionStorage.getItem('userName');
$scope.currentUserID = $window.sessionStorage.getItem('userID');
$scope.currentProfileID = $window.sessionStorage.getItem('profileID');
$scope.logOut = function() {
$window.sessionStorage.setItem('userName', null);
$window.sessionStorage.setItem('userID', null);
$window.sessionStorage.setItem('profileID', null);
$window.sessionStorage.setItem('currentJobID', null);
$window.sessionStorage.setItem('justApplied', 'false');
$scope.currentUserName = undefined;
$scope.currentUserID = undefined;
$scope.currentProfileID = undefined;
$window.location.href = getCareersView($window.location.pathname, '/JoinBlueScope');
};
});
これは私のHTMLコードです:
@*<li ng-click="logOut()" ng-show="currentUserName != undefined && currentUserName !=='null'"><a href="#" id="careerLoginLogoutLink">log out</a> </li>
<li ng-show="currentUserName == undefined || currentUserName ==='null'">@Html.ActionLink("Log in/Register", "Login", "Careers", routeValues: null, htmlAttributes: new { id = "careerLoginLogoutLink" })</li>*@
<li ng-show="currentUserName != undefined && currentUserName !=='null'"><a href="#" id="careerLoginLogoutLink" ng-click="logOut()">log out</a> </li>
<li ng-show="currentUserName == undefined || currentUserName ==='null'">@Html.ActionLink(linkText: "Log in/Register", actionName: "Login", controllerName: "Careers", protocol: "https", hostName: Request.Url.Authority, fragment: null, routeValues: null, htmlAttributes: new { id = "careerLoginLogoutLink" })</li>
コメントアウトされている2個のliタグがHTTPSなしで動作し、前のコードです。
私は自分のCareersControllerに[RequiredHttps]と他のすべてのコントローラを[ExitHttps]で装飾しました。私はExitHttps属性を実装するには、このリンクをたどっ:
http://www.primaryobjects.com/2012/04/23/moving-in-and-out-of-ssl-https-in-c-mvc-asp-net/
我々はそれを必要とする場合、私はこのコードとコントローラを提供することができます。彼らが「ログアウト」をクリックすると、私はただセッションをリセットして、それらを保護されたページに再ルーティングします。私は自分のコントローラにログアウトアクションがありません。私はログインアクションを持っています。
私の問題は、ログアウトしてもログインできないことです.hrefプロパティが無効であると不平を言うJQuery例外があります。私はコンテンツが混在していると思いますが、それを修正する方法はわかりません。
お願いします。
ありがとうございます。
質問でも表示されているjQueryコードはありません。 – charlietfl
jqueryコードがありません。 angularJSで使用されるJQueryでクラッシュします。これは無効な引数の例外です。 "href"プロパティは定義されていません。 angularJSでクラッシュした関数は次のとおりです。 $ rootElement.on( 'click'、function(event){ }); これは、次の行でクラッシュします。var absHref = elm.prop( 'href'); – MsBugKiller
[RequireHttps]属性を削除して2つの新しいliタグを削除し、古いliのコメントを外しても機能しますが、HTTPSはありません。だから私は問題がそれらの2つのliタグにあることを知っている。 – MsBugKiller