Something I encountered today at work, I tried to make a view that used a constant in a class in order to construct a query string. The code works perfectly fine when the constant is public but not when the constant is internal.
Here is the model:
public class LookupListModel
{
internal const string ContactGroupTypeList = "ContactGroupType";
// The below works fine
//public const string ContactGroupTypeList = "ContactGroupType";
}
And the view (correct @using is at the top):
<li>@Html.ActionLink("Contact group types", "Lookup", new { list = LookupListModel.ContactGroupTypeList })</li>
The view is compiled into another assembly, that’s why the
internal constdoes not work.