How to Use a normal link to submit a form
By FoxLearn 2/16/2024 9:04:01 AM 92
This post shows you How to submit a POST form using the <a href="..."> tag.
By default, In ASP.NET Core you can see your logout form as shown below.
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })"> <button type="submit" class="nav-link btn btn-link text-dark">Logout</button> </form>
If you want to use hyperlink to submit a form you can modify your html code as shown below.
<form asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Login", "Account", new { area = "Identity" })"> <a onclick="this.parentNode.submit();" class="dropdown-item btn btn-outline-grey btn-h-lighter-secondary btn-a-lighter-secondary"> <i class="fa fa-power-off text-warning-d1 text-105 mr-1"></i> Logout </a> </form>
As you can see, I'm using a link tag to submit a form with JavaScript by clicking a link.
- How to Minify HTML using WebMarkupMin in ASP.NET Core
- How to fix 'IMvcBuilder' does not contain a definition for 'AddNewtonsoftJson'
- How to fix System.InvalidOperationException: Scheme already exists: Identity.Application
- The name 'Session' does not exist in the current context
- How to fix 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'
- How to fix Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing
- How to Increase upload file size in ASP.NET Core
- How to fix LoginPath not working in ASP.NET Core
Categories
Popular Posts
C# Tutorial
07/20/2024
How to Download Microsoft SQL Server
06/22/2024
What Are RESTful Web Services?
02/19/2024
What is ARM architecture?
04/01/2024