Avatar of ITsolutionWizard
ITsolutionWizard
Flag for United States of America asked on

mvc, controller, c#

Inside of this MVC Controller, if I have javascript localstorage on html side, how can i send localstorage value to controller?

public ActionResult Info()
        {
            return View();
        }
HTMLC#JavaScript

Avatar of undefined
Last Comment
Miguel Oz

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Miguel Oz

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ITsolutionWizard

ASKER
I still dont get it
Miguel Oz

You just use the model in your C# method:
public ActionResult Info()
{
       var model = new MyModel(){
		MyValue  = "Fill up whatever value needs to be stored"
	};
	return View();
}

Open in new window

Implementation Summary: You must modify C# (controller, model) ,View (add hidden value and JS in your JS startup section)
ITsolutionWizard

ASKER
I still do not get it. Can you show me all codes included the js?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Miguel Oz

Could you please post your complete view code?
I will add the JS code there. I assume that C# should be straightforward.