I have created one .net core application that has below path for crud operations.
Create: http://localhost:1001/admin/123/app/456/user/Create
Update: http://localhost:1001/admin/123/app/456/user/Update
Select: http://localhost:1001/admin/123/app/456/user/Select
Writing below will solve the issue in the URL.
routes.MapRoute("CreateUser", "apps/{appId}/user/create",
defaults: new { controller = "User", action = "Create" });
How to include the same in .cshtml file i.e <a asp-action="Create" asp-controller="User"> Create User </a>
The quick help appreciated.
You can use asp-route-{value}
option to indicate route values in anchor tag helper:
<a asp-action="Create" asp-controller="User" asp-route-adminID="@Model.AdminId" asp-route-appId="@Model.AppId"> Create User </a>
Please consider that I assumed that adminId
and appId
values are provided in the Model of the page. If it's wrong, set appropriate variable instead of those in your code.
For more information, you can check the Microsoft documentation: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/anchor-tag-helper?view=aspnetcore-3.0#asp-route-value
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加