Reputation: 198
I am trying to pass an id from my controller to my view and encode this value in the Antixss function but I am getting an error.
This is my code
input type="hidden" name="Moderator" value="@AntiXss.HtmlAttributeEncode(ViewBag.ModeratorID)" readOnly="readonly" />
The error message is
The best overloaded method match for 'Microsoft.Security.Application.AntiXss.HtmlAttributeEncode(string)' has some invalid arguments
Upvotes: 1
Views: 940
Reputation: 69973
ViewBag
is a dynamic type, so call ToString()
on ModeratorID.
@AntiXss.HtmlAttributeEncode(ViewBag.ModeratorID.ToString())
Upvotes: 2