I am trying to send my session storage from the view to a controller.
Here is my code:
`$(document).ready(function () {
document.querySelector('.k-spreadsheet-sheets-bar-add').style.display = 'none';
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get('analysisId');
var sessionPassword = sessionStorage.getItem('analysisPassword').toString();
$.ajax({
url: "@Url.Action("Create", "Create")",
data: { id: id, sessionPassword: sessionPassword },
contentType: "application/json",
type: "GET",
success: function (response) {
if (response.success) {
alert("Daten wurden erfolgreich geladen!");
}
else if (response.passwordIncorrect) {
alert("Kein gültiges Passwort!");
window.location.href = 'http://localhost:55844/Index/Index'
}
},
error: function () {
alert("Error loading data.");
}
});
})`
I want to sen the “sessionPassword” to my Controller:
public ActionResult Create(int analysisId, string password)
This is how i want to recive it. The analysisId is sent correct, but the password not…
I did the “.toString” on the sessionPassword, i thought this was the problem, but it did not solve.