'How to load a Razor page from code in asp.net

I am new to Asp.net and Razor pages. Is there a way to load a Razor page from code in C#? I can't seem to find a way of doing that.

if(resultsName.Count == 0)
{
     CreateUser(username, userEmail);
                
     // load page
}
           


Solution 1:[1]

You can use Html.Partial or Html.RenderPartial to embed a partial view into your page. A partial is not a page(doesn't have @page directive) but I guess it might be what you are looking for.

if(resultsName.Count == 0)
{
     CreateUser(username, userEmail);
                
     Html.RenderPartial("AdminInfo");
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 000