I want to send some data when user clicks on this link
<a asp-action="ViewOthersProfile">@question.Questionaire</a>
and this is my action method
[HttpGet]
public ViewResult ViewOtherProfile()
{
return View("OtherProfile");
}
also,how we'll get it in action method. Thanks in advance
CodePudding user response:
//Use asp-route-myData for your data and you can name it whatever you want.
//asp-route-myData2, asp-route-data, asp-route-dog, ... you got the point.
<a asp-action="ViewOthersProfile" asp-route-myData="test string">@question.Questionaire</a>
//Here you can get your data as a parameter.
//However, the parameter name must be the last part of asp-route-myData. I mean 'myData'
[HttpGet]
public ViewResult ViewOtherProfile(string myData)
{
//And you can use myData whatever way you need
var result = myData "test2";
return View("OtherProfile");
}