Home > DeveloperSection > Articles > How to MVC communicate with Browser

How to MVC communicate with Browser

0 Comment(s)
 3179  View(s)
Rate this:

How to MVC communicate with Browser.

MVC application is communicate normally with web browser. It’s also accepts request from user and responds to the web browser in the same approach.

MVC File Structure & File Naming Standards

How to MVC communicate with Browser

                Standard directory structure and file naming standards is a very important part of MVC application. Within the application ROOT directory, contain directories and files which are model, view, Controller, Content, Script these are given below:

v  Content (directory)

¨      In this directory we can keep css and images files which is use in an application.

§  Themes(directory)

v  Controller (directory)

§  It will contain the controller file (e.i:-HomeController.cs).

v  View(directory)

§  Home (directory)

¨       This directory is contain the view file which name is index.cshtml

§  Shared (directory)

¨       This directory is containing the _layout.cshtml and Error.cshtml files.

§  web.config. (file).

§  _ViewStart.cshtml (file).

v  Script (directory)

§  It will contain JavaScript, jquery files.

v  Global.asax (file)

¨       It’s known as application file is used to server application level and session level events. Global.asax is complied its own assembly which is App_global.asax.dll

v  Web.config (file)

Life Cycle of an ASP.NET MVC application:

·         Application Initialization:

                In this step initiate the application and allow interacting with the server and running the                                                 Component.

·        Routing:

                In this step handle the request which is called Routing. It’s analyzes the request depending on                             the context and chooses which controller and which action has to be called. In MVC                                           application Routing iscreate a route data dictionary which is contain at least two entries:                                   ’Controller’ and ‘Action’.

·        Instantiate and execute controller:

                Now this step we have RequestContext object contain enough data to find which controller will be                                         instantiated. The MvcHandler depending by default on a DefaultControllerFactory object                                                            (System.Web.Mvc.DefaultControllerFactory) that is knows how to create a controller depending on the                                               RequestContext.

·         Invoking the Action Method:

                In this step the ActionInvoker arrange the remaining process. ActionInvoker finding the action                                                  and handling errors to filters and result processing. The ActionInvoker calls the action                                                                    execution. Then we get an ActionResult Object which is containing the result of the action.

·         Instantiate the Render View:

                It’s depending on View Engine it have take few steps which are given below:-

                                I.            The ViewResult asks the ViewEngine for the view via the FindView method. 

                              II.            Then return a ViewEngineResult containing an IView (System.Web.Mvc) implementation.

                            III.            IView contains the Render method which processes the view and writes the result in a TextWriter.

                            IV.            TextWriter directly associated to the Response by the ViewResult object.

                              V.            And ViewResult object view on Browser.

How to MVC communicate with Browser

Don't want to miss updates? Please click the below button!

Follow MindStick