Saving a list of items in Application State ASP.NET MVC ?
Posted
by Calibre2010
on Stack Overflow
See other posts from Stack Overflow
or by Calibre2010
Published on 2010-05-10T08:40:52Z
Indexed on
2010/05/10
8:44 UTC
Read the original article
Hit count: 240
Hi Guys,
I'm having a bit of trouble with knowing how I can save items from a list I have in Application state in the global.asax as- Application[""].
My controller basically takes in some user input, I then pass this to another classes Method as parameters it gets added to a list all the time. This data thats getting added to the list I want to store it, but without using a db. By using Application State. . I have been instantiating this class and calling its method to return the list of items but I dont think Application State is saving it.
Here is what I have so far. .
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
TimeLineInformation t = new TimeLineInformation();
IList<SWTimeEnvInfoDTO> g = t.getInfo();
Application["AppID"] = g;
}
^ Global.asax
IList<SWTimeEnvInfoDTO> result = new List<SWTimeEnvInfoDTO>();
public void returnTimeLineInfo(string SWrelease, string EnvName, DateTime SDate, DateTime EDate) {
SWTimeEnvInfoDTO myDTO = new SWTimeEnvInfoDTO();
myDTO.softwareReleaseName = SWrelease;
myDTO.environmentName = EnvName;
myDTO.StartDate = SDate;
myDTO.EndDate = EDate;
result.Add(myDTO);
getInfo();
}
public IList<SWTimeEnvInfoDTO> getInfo() {
return result;
}
^ class im calling
The SWTimeEnvInfoDTO type has get and set methods for the data.
I am calling the application from a View as well. It works with a string
Application["AppID"] = "fgt";
and shows this once i read it from my view.
© Stack Overflow or respective owner