1

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
2
  • Is ModeratorID a string? Have you tried to append .ToString()? Such as ViewBag.ModeratorID.ToString() Commented Feb 5, 2014 at 15:37
  • Thanks alot, I am grateful for you comment Commented Feb 5, 2014 at 16:08

1 Answer 1

2

ViewBag is a dynamic type, so call ToString() on ModeratorID.

@AntiXss.HtmlAttributeEncode(ViewBag.ModeratorID.ToString())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.