This project has moved. For the latest updates, please go here.

User.Identity does not get updated after login

Nov 18, 2013 at 8:14 PM
Edited Nov 18, 2013 at 8:15 PM
Well, first of all, i am pretty new to OWIN/Katana, so please excuse any mistakes i make :)

I am doing the following right now:
  • A user authenticates on the server via a POST request from my site,
  • then i try to fire a SignalR function on my server (WITHOUT page reload...), and the User.Identity property returns null, although it is the one from OWIN.
now, if i stop my javascript before the request (with alert()), and then navigate to ~/favicon.ico with a new tab ( i am making a new request here), then everything works fine...

I made a little research on this, and it seems that Katana updates those values at the beginning of the next request.
is that right?

if yes,
any ideas on how i can force OWIN/Katana to set the User.Identity property without a new request?

Thanks :)
Nov 18, 2013 at 8:22 PM
Just a little more context would help. What API are you getting the User from?
Nov 18, 2013 at 9:43 PM
Edited Nov 18, 2013 at 9:48 PM
Well, I am getting the User from
where Context is a
which has a
[System.Security.Principal.IPrincipal] User
that returns
and this using
for the values.

Also, the whole process looks like this:
  • GET: localhost/ <- Main Page
  • POST: localhost/api/Token <- Login Form submitted
  • <now i call the signalR code, which returns a NullReferenceException because User.Identity is set to a GeneralIdentity>
the whole signalR method.
public string GetUserName()
    return Context.User.Identity.Name;
Nov 18, 2013 at 10:57 PM
If you're using websockets then the existing request will not just update because you logged in. If you're doing ajax login then you need to stop the connection before logging in and restart after.
Nov 19, 2013 at 7:08 AM
Edited Nov 19, 2013 at 7:08 AM
Got a hold of dfowler in the SignalR JabbR channel, and figured out anything.

Thanks for the super fast help!