ASP.NET Core Identity: Can't Access Authorized Page After Authentication #50127
Unanswered
sachinkumarrajak
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm encountering an issue with my ASP.NET Core application's authentication and authorization setup. I have a protected page that requires users to be authenticated to access it. I've followed the standard practices for setting up ASP.NET Core Identity, but even after successfully logging in, I can't seem to access the protected page.
In my view page there are two login buttons "LoginwithIdentity" and "LoginWithSSOID" .here i am able to access "
authorize page by "LoginwithIdentity" but not able to access by "LoginWithSSOID" .
here the sample code that i have tried for both buttons
"LoginwithIdentity"
[HttpPost]
[AllowAnonymous]
public async Task Login(LoginViewModel model)
{
if (ModelState.IsValid)
{
var result = await signInManager.PasswordSignInAsync(
model.Email, model.Password, model.RememberMe, false);
"LoginWithSSOID"
var userName = "hardcodeduser"; // Replace with an actual username
var claims = new List
{
new Claim(ClaimTypes.Name, userName),
// Add other claims if needed
};
page that i want to access
[Area("Admin")]
[Authorize]
public class CategoryController : Controller
{
private readonly IUnitOfWork _unitOfWork;
this page i am not able to access using LoginWithSSOID
Beta Was this translation helpful? Give feedback.
All reactions