Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Why MVC?Roslyn can remove all the models.Just use VC.

$
0
0

I want talk about the MVC.

this is the aspnet mvc default action;

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";
            return View();
        }

We need ViewData to contain the Message field;

Why not like this?

        public IActionResult About()
        {
//The Content of About Page var Message = "Your application description page."; return View(); }

 Just create a model class with "ViewBag" name by roslyn compiler.

public class ViewBag
{
    //<summery>
    //The Content of About Page.
    //<summery>
    public string Message="Your application description page.";
}

when I write ViewBag. it prompt the field list with commit.

And it's cool.No dynamic and reflaction.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>