IdentityServer / IdentityServer3

OpenID Connect Provider and OAuth 2.0 Authorization Server Framework for ASP.NET 4.x/Katana
https://identityserver.github.io/Documentation/
Apache License 2.0
2.01k stars 763 forks source link

How to access session state in a custom userservice #3832

Closed vip8668 closed 7 years ago

vip8668 commented 7 years ago

I need access session in a custom user service to check captcha. But when i access HttpContext.Current.Session this object is null. Please tell me how to access Session in custom userservice. Thank!

brockallen commented 7 years ago

Inject the OwinEnvironmentService and access the request via the dictionary or wrap it with an OwinContext.

vip8668 commented 7 years ago

Can you give me a sample code. I had try
OwinContext ctx; public UserService(OwinEnvironmentService owinEnv) { ctx = new OwinContext(owinEnv.Environment); var request = ctx.Request; } but request doesn't have Session in this.

brockallen commented 7 years ago

What is session? ASP.NET Session State?

vip8668 commented 7 years ago

What is session? ASP.NET Session State?

Yes I Use Asp.Net MVC 5. I want to check the generated captcha and save to the session in the previous step

brockallen commented 7 years ago

I think it should be available if you're in IIS.