Adding View Without Model MVC 5

I need to create a simple view with 3 links to it (admin type page), I tried to add an index called View to a directory called Administration, but when I try to navigate to it, it throws up a resource that was not found. I'm new to MVC from Web Forms, so sorry if this is a stupid question;)

+3


source to share


2 answers


Firts Add a controller that will have an Index method. Right click on the index method and select Add View. Add all the Html you want to add to this view and your page will be ready without adding a model.



+6


source


You need to have a controller to render the view.

For example if you have AdminController

with a method similar to something like public ActionResult Index() { return View(); }

this would render a view index

where you could place your html / links etc.

The view itself doesn't need to model

, as you don't supply anything when you return View()

.



Then you can go to the page http://xxx/Admin/Index

or, http: // xxx / Admin / '.

Worth looking around SO and other various sites for MVC requests!

Good luck.

+2


source







All Articles