A free and open-source web framework that enables developers to create web apps using C# and HTML, developed by Microsoft.
Hi @Arthur Ochoa ,
THE ISSUE: Access to HttpContext outside a Razor component returns a null value (i.e. in a separate Class file).
Please set a break point in the AuthenticateSite() method, then debug your code, the issue relates the IServiceProvider, the _services is null. So, it will throw the ArgumentNullException: Value cannot be null. (Parameter 'provider' error.
Try to comment or remove _services relate code, the redirect action should work.
public void AuthenticateSite()
{
//_httpContextAccessor = _services.GetRequiredService<IHttpContextAccessor>();
_httpContextAccessor.HttpContext.Response.Redirect("https://www.site1.com/auth" + "?return_url=" + "https://www.mysite.com/blazorapp");
}
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
Dillion