GithubHelp home page GithubHelp logo

HttpContext with user is null about hybridblazor HOT 2 OPEN

jdtcn avatar jdtcn commented on May 22, 2024
HttpContext with user is null

from hybridblazor.

Comments (2)

jdtcn avatar jdtcn commented on May 22, 2024

Hi,

It's a strange situation because HttpContext.User must have non-null value regardless authentication state. Have you made any changes in the project files? What environment do you use? Is httpContextAccessor null or httpContextAccessor.HttpContext is null?

изображение

from hybridblazor.

jareksgit avatar jareksgit commented on May 22, 2024

Hello,

in my local environment the whole thing ran without any problems and I can also reproduce your debugging result locally.
After deploying it on Azure, I became aware of the problem. Except for the database and some settings, I made no changes and deployed it 1 to 1.

After my research, see Stackoverflow Answer 1 with a small link in it to Stackoverflow Answer 2.
And there I found a link to the official documentation on this matter: Documentation Link
And in it the note that the HttpContext isn't guaranteed to be available within the IHttpContextAccessor, nor is it guaranteed to be holding the context that started the Blazor app.

The Blazor Server Starter via Visual Studio does not visibly access the httpcontext to query the user, but uses a helper method (RevalidatingServerAuthenticationStateProvider) to get our current user state. Maybe this is an approach to bypass the whole thing with the HttpContext?

from hybridblazor.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.