0
我遇到了無盡的重定向問題。我正試圖讓每個標籤獲得一個新的會話ID。我以ASP.Net無Cookie新會話ID無盡重定向
$.ajax({
type: "POST",
url: $('#setSessionUrl').data('url')+'?windowName='+window.name,
async: false,
success: function (result) {
if (result.relocate == false) {
var url = $('#loginUrl').data('url');
window.location = url;
}
},
error: function() {
var url = $('#loginUrl').data('url');
window.location = url;
}
});
做這項工作,我的控制器動作看起來像
LoginViewModel loginViewModel = new LoginViewModel();
SessionIDManager sessionIdManager = new GuidSessionIdManager();
var context = System.Web.HttpContext.Current;
string newId = sessionIdManager.CreateSessionID(context);
bool redirected, isAdded;
sessionIdManager.SaveSessionID(context, newId, out redirected, out isAdded);
if (!string.IsNullOrEmpty(update))
{
loginViewModel.UpdateStatus = update;
}
return View(loginViewModel);
這是成功地生成新的會話ID但它是導致無限重定向循環。
我已經加入這個網絡配置,但沒有運氣,因爲我與小提琴手注意到我得到一個狀態碼302我暫時移除窗體身份驗證,但沒有運氣有任何
<location path="Views/Login" allowOverride="false">
<system.web>
<authorization>
<allow users="?"/>
<allow users="*"/>
</authorization>
</system.web>
</location>
我SetSessionId動作是這樣的
[HttpPost]
public ActionResult SetSessionId(string windowName)
{
if (Session["WindowId"] == null)
{
Session["WindowId"] = windowName;
return Json(new{relocate=true});
}
string window = Session["WindowId"].ToString();
if (window.ToLower()==windowName.ToLower())
return Json(new { relocate = true });
return Json(new { relocate = false ,windowId=windowName});
}
我正在使用無Cookie會話。目標是允許多個會話並且不註銷原始會話。
我加
context.Response.Redirect(Url.Action("Index"),false);
我的登錄操作,現在,它不會無休止地重定向。但是原始選項卡會被註銷。一旦我在兩個標籤上登錄,我都有單獨的會話。我怎樣才能避免在原始標籤上註銷?
我忘了補充我的其他動作判定它是否是一個新的窗口或不 [HttpPost] 公衆的ActionResult SetSessionId(字符串windowName) { 如果(會話[ 「WINDOWID」] == NULL){ 會話[「WindowId」] = windowName; return Json(new {relocate = true}); } string window = Session [「WindowId」]。ToString(); (window.ToLower()== windowName.ToLower()) return Json(new {relocate = true}); return Json(new {relocate = false}); } –
如果您有更多信息,請**編輯**您的問題 - 不要將其作爲評論 – freefaller