Ich kann die Sitzungswerte nicht abrufen, wenn ich eine andere Operation starte, während eine Operation ausgeführt wird, wie unten;MVC Parallele Transaktionen und Sitzungsobjekte
$.ajax({
type: 'GET',
cache: false,
url: '/Home/StartOperation',
dataType: 'json',
data: { customerId: $("#txtCustomerId").val() },
error: function (xhr, status, error) {
$("#textlabel").text(error)
},
success: function (result) {
$("#textlabel").text(result.Result)
}
});
Steuerungsseite;
public ActionResult StartOperation(string customerId)
{
Session["OperationId"] = "operationid";
// Some web api transactions (This operations takes a few minutes.)
var data = new { Result = "Operation Completed." };
return Json(data, JsonRequestBehavior.AllowGet);
}
Ich bin sicher, über Session["OperationId"]
ist nicht null, und dann meine Abbrechen Ich nenne Aktion während Web-api Transaktionen im Gange;
$(function() {
$('#btnCancelLogin').on('click', function() {
$.ajax({
type: 'GET',
cache: false,
url: '/Home/CancelOperation'
});
});
});
Steuerungsseite;
public ActionResult CancelOperation()
{
String operationId = Session["OperationId"] as String // return null
//Cancel operations
}
Warum Session["OperationId"]
auf CancelOperation()
Methode immer null ist? Danke für Ratschläge.
Try sein: '(String) Session [" OperationId "]' – Sajal
@SajalS, hat nicht funktioniert, Außerdem habe ich versucht, ohne zu werfen, aber Session ["OperationId"] war null. – oyenigun
Können Sie die Browser-Konsole öffnen und prüfen, ob Session [Key] während der StartOperation-Methode tatsächlich erstellt wird? – Sajal