I was able to add identity memebership of asp core and to create database, but i have seen that in the project there is a register new user view, but cannot able to manage.
I've tried to reach view from a new action method in home controller , but the path of view is not reachable.
First you need to pick a technology. Are you using mvc actions and views or are you using razor pages. You either route to an action or a razor page. You can not use a razor page as a view. Also routes don’t include the razor extension.
I'm not sure what you are trying to do but the project is a Razor Pages not MVC. Plus the project source is open. I recommend sticking with Razor Page.
Actually, the identity pages you found in the tutorial are Razor pages and you could not use View() to access them.
Instead, you could access them using Redirect() since they already are enabled in
startup.cs file.
More details, you could refer to below codes. I construct a demon to demonstrate that how you could access the Razor page while the demo might not the same as your project.
HomeController.cs
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
public IActionResult Test()
{
return Redirect("/Identity/Account/Register");
}
}
Register.cshtml Location:
Demo:
Hope this can help you.
Best regards,
Sean
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
I would be glad if it could help you.
If you still meet problems, you can post it here and people here will be happy to solve the problem.
If you find that the answer does solve your issues, I suggest you mark the answer. This will help other people who faces the same issue to find the right answer faster.
Best regards,
Sean
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
5 Points
37 Posts
Unable to reach register new user view in identity server 4 demo project
May 02, 2020 05:28 PM|first100|LINK
Hello,
Im using identityserver4 with asp core identity to realize a demo project , i following a tutorial at this link:
https://deblokt.com/2020/01/24/04-part-1-identityserver4-asp-net-core-identity-net-core-3-1/
I was able to add identity memebership of asp core and to create database, but i have seen that in the project there is a register new user view, but cannot able to manage.
I've tried to reach view from a new action method in home controller , but the path of view is not reachable.
I have attached my project :
https://1drv.ms/u/s!AiqYLxIc1eZ0mIpxxqabWiO4AMmC9w?e=z4yN9K
i have tried to put link to view in index view like
<a href="Areas\Identity\Pages\Account\Register.cshtml" >Register as a new user</a>
or in my account controller to put :
[HttpGet]
public IActionResult Register()
{
// path : 04. PART-3 IdentityServer4 ASP.NET Core Identity\src\IdentityServer\Areas\Identity\Pages\Account\Register.cshtml
return View("~/Areas\Identity\Pages\Account\Register");
}
without result.
Can anyone help me?
Thanks
*PhotoBallot.net*
All-Star
58464 Points
15787 Posts
Re: Unable to reach register new user view in identity server 4 demo project
May 02, 2020 06:19 PM|bruce (sqlwork.com)|LINK
First you need to pick a technology. Are you using mvc actions and views or are you using razor pages. You either route to an action or a razor page. You can not use a razor page as a view. Also routes don’t include the razor extension.
All-Star
53691 Points
24030 Posts
Re: Unable to reach register new user view in identity server 4 demo project
May 02, 2020 06:24 PM|mgebhard|LINK
I'm not sure what you are trying to do but the project is a Razor Pages not MVC. Plus the project source is open. I recommend sticking with Razor Page.
https://github.com/Deblokt/IdentityServer4Demos.NETCore31/blob/master/04.%20PART-1%20IdentityServer4%20ASP.NET%20Core%20Identity/src/IdentityServer/Areas/Identity/Pages/Account/Logout.cshtml.cs
Contributor
3020 Points
889 Posts
Re: Unable to reach register new user view in identity server 4 demo project
May 04, 2020 03:57 AM|Sean Fang|LINK
Hi first100,
Actually, the identity pages you found in the tutorial are Razor pages and you could not use View() to access them.
Instead, you could access them using Redirect() since they already are enabled in startup.cs file.
More details, you could refer to below codes. I construct a demon to demonstrate that how you could access the Razor page while the demo might not the same as your project.
HomeController.cs
public class HomeController : Controller { private readonly ILogger<HomeController> _logger; public HomeController(ILogger<HomeController> logger) { _logger = logger; } public IActionResult Index() { return View(); } public IActionResult Privacy() { return View(); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } public IActionResult Test() { return Redirect("/Identity/Account/Register"); } }
Register.cshtml Location:
Demo:
Hope this can help you.
Best regards,
Sean
Member
5 Points
37 Posts
Re: Unable to reach register new user view in identity server 4 demo project
May 04, 2020 09:20 AM|first100|LINK
thank you to all for the replies, I understood my mistake
*PhotoBallot.net*
Contributor
3020 Points
889 Posts
Re: Unable to reach register new user view in identity server 4 demo project
May 05, 2020 05:01 AM|Sean Fang|LINK
Hi first100,
I would be glad if it could help you.
If you still meet problems, you can post it here and people here will be happy to solve the problem.
If you find that the answer does solve your issues, I suggest you mark the answer. This will help other people who faces the same issue to find the right answer faster.
Best regards,
Sean