Just curious how or is there's a method in asp that can hide the parameter in the url without using jquery, javascripts? im using asp.net core mvc in my project and passing parameters from view to controller through tag helpers such as asp-route-Identifier etc.
sample a tag:
<a asp-controller="Exposure" asp-action="ViewPolicies" asp-route-Identifier="@ViewBag.Identifier"><i ></i> View Information: <b> @ViewBag.TotalPolicy</b></a>
CodePudding user response:
If you don't want to show parameter in url, You can put the data in the form then send post request. Refer to this code:
public class PassModel
{
public string Value { get; set; }
}
View
@model PassModel
<form asp-controller="Exposure" asp-action="ViewPolicies" method="post">
<input type="hidden" asp-for="@Model.Value" value="@ViewBag.Identifier"/>
<button type="submit">View Information: <b>@ViewBag.TotalPolicy</b> </button>
</form>
Controller
[HttpPost]
public IActionResult ViewPolicies(PassModel model){
//......
}.
If you want to hidden url by using <a></a>
and asp-route-xx
, you need to use js or jq, please refer to this issue.