0

I have a small confusion in Asp.Net MVC

How rendering works in Asp.net MVC? We invoke View function - > Which will find the view and ask ViewEngine to parse it. Because of ViewEngine final outcome is HTML.

1)Whatever ViewData we create its available inside View. My understanding is ViewData and View function both are part of controller base class which makes ViewData available inside View function. Is it correct?

2)Finally Whats the point with WebViewPage class. ViewData keyword we use inside View(.cshtml) page is coming from the WebViewPage class. What role WebViewPage plays here.

I will really appreciate If you can point me with some good resource to understand the same

skaffman
  • 398,947
  • 96
  • 818
  • 769
Sukesh Marla
  • 178
  • 11
  • I suggest you read this document - http://i3.asp.net/media/4773381/lifecycle-of-an-aspnet-mvc-5-application.pdf?version_id=&cdn_id=2015-04-01-001. Welcome with any particular follow up questions. – SBirthare Apr 07 '15 at 04:13

2 Answers2

0

1) ViewData is merely a dictionary of objects that you can fill in the Controller and retrieve within the view. Since it is a dictionary of objects you need to cast the data back into the type it was to make full use of it.

2) WebViewPage is the base type of a razor page. It is the defined class which razor pages are compiled into at runtime. The web.config inside the views folder specifies the pageBaseType of the razor pages specifically to WebViewPage. These are two good resources regarding why its use and how you can extend it. Link1 and Link2.

Judge Bread
  • 501
  • 1
  • 4
  • 13
  • I know about ViewData. My Problem is i want to undertsand How ViewData get Available inside View (internals of it). Secondly How View function works internally – Sukesh Marla Apr 07 '15 at 04:51
0

Go peek inside he source code that renders the views visit msdn

Victor C
  • 70
  • 1
  • 8
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Rohit Gupta Aug 10 '15 at 18:54