1 year ago

#287775

test-img

Cliffi

How do I set language once the client application signed in with identity server

I have a setup where a client application signs in using OWIN middleware / oauth with a central identity server. The return request from the identity server also includes a language claim for the current user i.e. "en_US".

The client application is a .net 4.8 web application and allows to set the language locally by clicking on a link (route value "culture" is modified which is part of the default route). Below a sample Url for better understanding

https://MyApplication/en-US/Home/Index

Click on the language link makes this

https://MyApplication/fr_FR/Home/Index

The question is how can I set the language once after the client successfully authenticated with the identity server??? In my client application I add custom claims/roles using global.asax and the Application_PostAuthenticateRequest() method.

Application_PostAuthenticateRequest()
{
/// Add custom claims here
}

This method gets called on every request so I can't use it to update the language of the current request as it would reset any local changes to the language immediately on the next request. Local changes of the language should not be overruled for the current session.

I tried setting it in Session_Start that would be ok but the problem is that Session_Start is called before the client is authenticated, so I don't have any claim at this point.

What I actually would need is a method that is called once after the client is authenticated. So actually it would be similar to Session_Start but happens after the first request is authenticated. Anyone had a similar situation or can share an idea is welcome!

c#

asp.net-mvc

owin

openid

global-asax

0 Answers

Your Answer

Accepted video resources