I'm using Unity to inject a context and using the following lifetime manager...
public class HttpContextLifetimeManager<T> : LifetimeManager, IDisposable
{
#region IDisposable Members
public void Dispose()
{
RemoveValue();
}
#endregion
public override object GetValue()
{
object value = HttpContext.Current.Items[typeof (T).AssemblyQualifiedName];
return value;
}
public override void RemoveValue()
{
HttpContext.Current.Items.Remove(typeof (T).AssemblyQualifiedName);
}
public override void SetValue(object newValue)
{
HttpContext.Current.Items[typeof (T).AssemblyQualifiedName]
= newValue;
}
}
I have to restart the VS development server to get page one to show the new values.
So how can a context a) live between page requests and b) be specific to a page?
This had nothing to do with EF. The generated UI was out of sync with the entity and the entity was throwing validation errors which weren't being reported in the UI. It would have helped if the scaffolding templates had generated a validation summary which didn't only show model level errors.