Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to get access to Request.HttpContext (User-Agent-String) in startup.cs... (RC)?

$
0
0

I have to query the User-Agent-string one time (by startup) in my app (e.g. to set the platform of the client).
I then need the platform in the whole app. Therefore I set a session-variable.
The logical place to do that, would be startup.cs.
As I have not found a way for accessing Request.HttpContext in startup.cs, I had to implement the query of the UAS in all controllers and then call a central function that make some operations and give back a string which I then set to a session variable (also in all controllers):

HttpContext.Session.SetString("Plattform", cPlatform);

This is far away to be nice...
Further, I need to get the client-IP-Address and also found now way (it seems as this stuff is not included anymore in RC...)?

Thanks for any reply... 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>