ASP.NET MVC Enum in Session

I am storing an Enum in the session:

Session.Add("workflowstatus", workflowstatus);

Later on I am trying to retrieve the Enum by doing:

model.SelectedWorkflowStatus = Session["workflowstatus"];

Which obviously doesn't work. Any idea how I can convert the Session["workflowstatus"]; back to an Enum?

Answers


The Session will return the value back as object, you just need to cast it to the appropriate type i.e.

model.SelectedWorkflowStatus = (WorkflowStatusType)Session["workflowstatus"];

Need Your Help

Sending request each n seconds with libcurl in c

c curl libcurl

I am trying to figure out how to make a request in c each n seconds. I want it to be asynchronous, meaning the requests are made even if the previous ones have not been responded.

Why does LayoutKind.Sequential work differently if a struct contains a DateTime field?

c# datetime marshalling structlayout

Why does LayoutKind.Sequential work differently if a struct contains a DateTime field?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.