Ganesh
Ganesh

Reputation: 31

What does return View(model) means in ASP.NET MVC?

I am new to ASP.NET MVC programming. I would want to know what does the return View(model) does.

    public ActionResult CreateProducts(ProductsModel model)
    {
        /// Some code here.            

        return View(model);
    }

Upvotes: 0

Views: 5455

Answers (3)

Mihir Kale
Mihir Kale

Reputation: 1118

When you hit the URL, something like http://blah-blah/Products/CreateProducts, a controller(Product controller in this case) object is created and initialized.

This controller contains the action method CreateProducts which is called via the above url.

The controller's job is to bind the Model and the View and render it as HTML in the Browser.

This is precisely done by the View(model) method.

Hope it helps..

Upvotes: 1

It will return View (html page) with Name "CreateProducts" and controller pass ProductsModel data in "model", which will use to bind with render html.

Upvotes: 1

Related Questions