Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify Dictionary<string,string> in ASP-all-route-data to pass query string

I have the following action link in my view <a asp-controller="Messages" asp-action="Index">Connect</a>

I need to pass a query string parameter with custom name (asp-route-id is in this case unacceptable) through asp-all-route-data is there a way how can I specify just the dictionary there, rather than creating new dictionary somewhere in the view and pass it to the attribute?

I have tried to do it following way, but without a luck.

 <a  asp-all-route-data="["user"[email protected]]" asp-controller="Messages" asp-action="Index">Connect</a>
like image 881
Lukáš Václavek Avatar asked Jan 27 '23 06:01

Lukáš Václavek


1 Answers

You can specify the Dictionary inline if you want, like this:

<a asp-all-route-data="@(new Dictionary<string, string> { { "user", item.PetSitter.UserId } })" asp-controller="Messages" asp-action="Index">Connect</a>
like image 181
hujtomi Avatar answered Jan 30 '23 01:01

hujtomi