Subby
Subby

Reputation: 5480

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?

Upvotes: 0

Views: 698

Answers (1)

James
James

Reputation: 82136

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"];

Upvotes: 2

Related Questions