how to use localstorage in WEB API .net 6

Fazioli Amboina 61 Reputation points
2022-09-20T15:43:02.077+00:00

Been googling for 4 hours now how to do this on WEB API, in .net6.

how do i set a value in browser storage, and how do i retrieve it?

like:

Localstorage{"SomeID"} = "SomeValue"

return Localstorage{"SomeID"}

ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
343 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 66,706 Reputation points
    2022-09-20T16:10:16.407+00:00

    as localStorage is a browser feature only available to javascript, webapi has no access.

    to set and read a value, create an html webpage. add the javascript. sample:

    <html>  
      <script>  
        const dosave = () => localStorage.setItem('value', document.getElementById("value").value);  
        const doret = () => alert(localStorage.getItem('value'));  
      </script>  
      <body>  
      value to store: <input id="value" type="text"><br>  
      <button type="button" onclick="dosave()">save</button>    
      <button type="button" onclick="doret()">retrieve</button>    
      </body>  
    </html>  
      
      
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.