I have this action method in C #:
public ActionResult Index() { ViewBag.Message = "Hello"; return View(); }
And this view (Index.cshtml):
<h2>@ViewBag.Message</h2>
And this leads to the expected "Hello" on the page.
I want to make a controller in F #. I tried
type MainController() = inherit Controller() member x.Index() = x.ViewBag?Message <- "Hello" x.View()
And this causes the error message "Method or object constructor" op_DynamicAssignment "not found".
I looked through some of the F # code examples for a dynamic statement, and I don't see anything shorter than a few description pages and many lines of code. They seem too general for this setter property.
source share