Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Add IsAvailable to ISession #634

Closed
JunTaoLuo opened this issue May 19, 2016 · 4 comments
Closed

Add IsAvailable to ISession #634

JunTaoLuo opened this issue May 19, 2016 · 4 comments
Assignees
Milestone

Comments

@JunTaoLuo
Copy link
Contributor

As part of aspnet/Session#113. We realized there is value in adding a IsAvailable property to the ISession interface to indicate whether the session has loaded correctly. This value can depend on factors such as whether the underlying caching data is available and is valid.

@kichalla
Copy link
Member

cc @ajaybhargavb

@JunTaoLuo @Tratcher is the expectation that where ever session is required to be present, the code should check for IsAvailable explicitly and throw? (for example: MVC's TempData depends on it...can you file an issue on Mvc to update it https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/SessionStateTempDataProvider.cs#L61)

@JunTaoLuo
Copy link
Contributor Author

@kichalla The idea is that if the Session is not available, you should not depend on it to give you any information. You should have some fall back logic to handle it and depending on the case, throwing and failing the request may or may not be the right thing to do.

Note that if the session is not available, it will no op when you try to access or modify it. TryGetValue() will return false and Set/Remove will no-op.

@Tratcher
Copy link
Member

It's up to the caller to decide what to do. IsAvailable is just a hint to the app so it can fail more gracefully if expected values are not present.

@kichalla
Copy link
Member

Ok sure, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants