Hello everyone how to get localstorage value in .cshtml file and set condition
Loading
Hello everyone how to get localstorage value in .cshtml file and set condition
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Jan 21, 2022, 10:51 AM
Md SarfarajPosted Jan 21, 2022, 5:17 AM
Muhammad Imran AnsariPosted Jan 20, 2022, 2:13 PM
You can set the local or session storage from asp.net (indirectly). Since we can set up javascript code in asp.net and insert into the client side, there's no difference with the session or local storage.
Try this from server side
string script = string.Format("sessionStorage.userId= '{0}';", "12345"); ClientScript.RegisterClientScriptBlock(this.GetType(), "key", script, true);