I've always used New With {}
with no issues. Why is this different?
Razor VB.NET code
Using Ajax.BeginForm(New AjaxOptions With {.HttpMethod = "Post"})
@* no problem *@
End Using
Using Ajax.BeginForm(New With {.HttpMethod = "Post"})
@* Value of type '<anonymous type>' cannot be converted to 'System.Web.Mvc.Ajax.AjaxOptions'. *@
End Using
An anonymous type (New With {}
) does not extend/inherit AjaxOptions
- and an object conforming to AjaxOptions
is required by BeginForm
.