0
Close Secion의 사용자가 Session [ "UserName"]에 할당 된 값이 null이지만 테스트를 수행 할 때 로그인 및 재발신을 통해 문제없이 들어갈 수 있기를 바랍니다. 메인 페이지,하지만, 다른 페이지로 이동하자마자 내 계정이 더 이상 기록되지 않습니다. 누군가가 떠나고 싶을 때만 Session [ "UserName"]에 null 값을 할당하는 방법을 말해 줄 수 있습니까? 당신은 서버와 클라이언트 코드를 혼합하는ASP.NET MVC : 세션 값 자바 스크립트 설정
@if (Session["UserName"] != null)
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hi " + Session["UserName"] + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li>
@Html.ActionLink("Logout", "Login", "Account", null, new {@class = "btn-set-null"})
</li>
</ul>
}
<script type="text/javascript">
$(function() {
$("btn-set-null").on('click', funtion(){
@(Session["UserName"] = null);
})
});
</script>
>이 멋진 답변 확인 https://stackoverflow.com/questions/8711998/how-set-session-variables-in-asp-net-mvc-3-with-jquery – ArunPratap