Apr 15 2022 01:02 AM
Hi there,
I can get the identity name through "HttpContext.User.Identity.Name" in localhost.
But when I deployed to my server, it always fail to get the identify name.
P.S. Both machine are in the same domain
How do I fix this issue?
Controller.cs:
var user = HttpContext.User.Identity.Name ?? "";
Startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
app.UseStaticFiles();
app.UseRouting();
app.UseSession();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
Apr 18 2022 08:13 PM
Hi @HsuanC,
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang