I have a key value local storage in my browser as shown in the image below. I want to retrieve this information with ASP.NET Core MVC. Once I retrieve it, I could use it for for example storing it in a database for later use.
How can I access this information with ASP.NET Core 3.1 MVC?
//ADDITIONAL INFORMATION// Based on the two answers (Nadeem and Abdelrahman), I did check on this and somehow I think the best way would be to go with Ajax. In another post in Stackoverflow: Passing localstorage to controller using Ajax
I see an example as below:
function sendLocalStorage() {
var JsonLocalStorageObj = JSON.stringify(localStorage);
//var test = ["test1", "test2", "test3"];
$.ajax({
url: "/MyControllersName/Test",
type: "POST",
data: { JsonLocalStorageObj: JsonLocalStorageObj },
success: function (result) {
alert(result);
}
});
}
I wonder though how within this function you can define which localstorage value you will post? I mean how do you select the key for the value that you want to post?
Second, as the server application uses EF identity, I assume some security need to be posted with this request. I checked in the developer tools of the browser, I have a cookie as shown below. Does some information of this need to be posted by the function?