0

I have just started looking at MVC. The tutorials look great and make sense but all tutorials I saw are based on database model. I am assuming that I could have object structure saved in session and return that if I wanted?

Also suupose my model for a controller was a student, in one action can I return a student and in another in same controller return studentWithCourses but use the same view?

I am sure I need to read some books first but I am looking general theories which will help me get started

Thanks H

Hassan Hussein
  • 157
  • 1
  • 11

2 Answers2

1

Yep, you can pass different models to the same view.

There is no requirement for a database, just code up what you need.

If you are going to read a book I can't recommend the Steve Sanderson 'Pro ASP.NET MVC Framework books' enough.

Community
  • 1
  • 1
Neil Thompson
  • 6,356
  • 2
  • 30
  • 53
  • Isn't that too old now. Should I read about MVC 4 books rather than old books? – Hassan Hussein Aug 16 '12 at 08:56
  • The MVC4 version isn't out in the UK until Dec 12 2012 - I think they are such good books it's worth reading the MVC 3 one now and piecing mvc 4 changes (like the web api stuff) together from other sources – Neil Thompson Aug 16 '12 at 09:58
0

In answer to your questions.

You dont have to use a database so you can store them where you want. Not sure session is the best place, but its possible.

You can use the same view for multiple actions yes, you would just need to hide the bits that were not relevant to each model.

Gaz Winter
  • 2,924
  • 2
  • 25
  • 47
  • Suppose I had an eLearnign type site where user goes through a series of pages and that I load page data from XML (material to read and questions) files then add checkboxes and combo boxes and user will select them. If user selected correct ones he will be forwarded to the next page otherwise a message is displayed. would this kind of scenario be easily done in MVC – Hassan Hussein Aug 16 '12 at 09:04
  • I dont see why it wouldnt be. – Gaz Winter Aug 16 '12 at 10:31