Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

asp-page-handler is not able to call the post method in pagemodel

$
0
0

am trying to call a post method in my page model using asp-page-handler(binded into button). When i click on the button am getting 500 internal server error.Below is the code I tried.

Cshtml:

<form method="post" id="EditForm" class="form-horizontal">    <div class="col-xs-2 lead pull-right"><input type="submit" formmethod="post" value="Edit Employee" asp-page-handler="EditEmployee" asp-route-type="level1" class="btn btn-primary" /></div></form>

Cshml.cs (Page Model)

public IActionResult OnPostEditEmployee(string type)
{
	//Edit operation
}

After running the application the button is rendered as below

<input type="submit" formmethod="post" value="Edit Employee" class="btn btn-primary" formaction="Employee?type=level1&handler=DeleteCategory">

formaction for the button is wrong, Page handler should append to url first and it should be like formaction="Employee?handler=DeleteCategory&type=level1".

I tried calling the pagemodel method by removing the parameter type and for that also  am getting 500 internal server error.

 Note:  am using .net core 2.2 framework

Please help me to come out of this issue.

Thanks


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>