Hello everyone how to get localstorage value in .cshtml file and set condition
How to get value in c#
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Jan 21, 2022, 5:51 AM EST
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Jan 20, 2022, 9:13 AM EST
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);Md SarfarajRank #194 · 12.4K reputationPosted Jan 21, 2022, 12:17 AM EST