Jinal desai .net

Articles from Jinal Desai .NET
ASP.NET MVC 3 Interview Questions
2011-10-21 15:10:50 Jinal Desai

What is MVC?

MVC is a framework methodology that divides an application’s implementation into
three component roles: models, views, and controllers.

“Models” in a MVC based application are the components of the application that
are responsible for maintaining state. Often this state is persisted inside a database
(for example: we might have a Product class that is used to represent order data
from the Products table inside SQL).
“Views” in a MVC based application are the components responsible for displaying
the application’s user interface. Typically this UI is created off of the model data (for
example: we might create an Product “Edit” view that surfaces textboxes,
dropdowns and checkboxes based on the current state of a Product object).
“Controllers” in a MVC based application are the components responsible for
handling end user interaction, manipulating the model, and ultimately choosing a
view to render to display UI. In a MVC application the view is only about displaying
information – it is the controller that handles and responds to user input and
interaction.

Which are the advantages of using MVC Framework?

MVC is one of the most used architecture pattern in ASP.NET and this is one of
those ASP.NET interview question to test that do you really understand the
importance of model view controller.
1. It provides a clean separation of concerns between UI and model.
2. UI can be unit test thus automating UI testing.
3. Better reuse of views and model. You can have multiple views which can point to
the same model and also vice versa.
4. Code is better organized.

What is Razor View Engine?

Razor view engine is a new view engine created with ASP.Net MVC model using
specially designed Razor parser to render the HTML out of dynamic server side
code. It allows us to write Compact, Expressive, Clean and Fluid code with new
syntaxes to include server side code in to HTML.

What is namespace of asp.net mvc?

ASP.NET MVC namespaces and classes are located in the System.Web.Mvc
assembly.

System.Web.Mvc namespace
Contains classes and interfaces that support the MVC pattern for ASP.NET Web
applications. This namespace includes classes that represent controllers, controller
factories, action results, views, partial views, and model binders.

System.Web.Mvc.Ajax namespace
Contains classes that support Ajax scripts in an ASP.NET MVC application. The
namespace includes support for Ajax scripts and Ajax option settings.

System.Web.Mvc.Async namespace
Contains classes and interfaces that support asynchronous actions in an ASP.NET
MVC application

System.Web.Mvc.Html namespace
Contains classes that help render HTML controls in an MVC application. The
namespace includes classes that support forms, input controls, links, partial views,
and validation.

How to identify AJAX request with C# in MVC.NET?

The solution is in depended from MVC.NET framework and universal across server-
side technologies. Most modern AJAX applications utilize XmlHTTPRequest to send
async request to the server. Such requests will have distinct request header:

X-Requested-With = XMLHTTPREQUEST




MVC.NET provides helper function to check for ajax requests which internally
inspects X-Requested-With request header to set IsAjax flag.

HelperPage.IsAjax Property
Gets a value that indicates whether Ajax is being used during the request of the Web
page.

Namespace: System.Web.WebPages
Assembly: System.Web.WebPages.dll

However, same can be achieved by checking requests header directly:

Request["X-Requested-With"] == “XmlHttpRequest”

What is Repository Pattern in ASP.NET MVC?

Repository pattern is usefult for decoupling entity operations form presentation,
which allows easy mocking and unit testing.

“The Repository will delegate to the appropriate infrastructure services to get the job
done. Encapsulating in the mechanisms of storage, retrieval and query is the most
basic feature of a Repository implementation”

“Most common queries should also be hard coded to the Repositories as methods.”

Which MVC.NET to implement repository pattern Controller would have 2
constructors on parameterless for framework to call, and the second one which
takes repository as an input:
class myController: Controller
{
    private IMyRepository repository;

     // overloaded constructor
     public myController(IMyRepository repository)
     {
         this.repository = repository;
     }
// default constructor for framework to call
      public myController()
      {
          //concreate implementation
          myController(new someRepository());
      }
...

      public ActionResult Load()
      {
          // loading data from repository
          var myData = repository.Load();
      }
}

What is difference between MVC(Model-View-Controller) and MVP(Model-
View-Presenter)?

The main difference between the two is how the manager (controller/presenter)
sits in the overall architecture.

All requests goes first to the Controller
MVC pattern puts the controller as the main ‘guy’ in charge for running the show. All
application request comes through straight to the controller, and it will decide what
to do with the request.

Giving this level of authority to the controller isn’t an easy task in most cases. Users
interaction in an application happen most of the time on the View.

Thus to adopt MVC pattern in a web application, for example, the url need to
become a way of instantiating a specific controller, rather than ‘simply’ finding the
right View (webform/ html page) to render out. Every requests need to trigger the
instantiation of a controller which will eventually produce a response to the user.

This is the reason why it’s alot more difficult to implement pure MVC using Asp.Net
Webform. The Url routing system in Asp.Net webform by default is tied in to the
server filesystem or IIS virtual directory structure. Each of these aspx files are
essentially Views which will always get called and instantiated first before any other
classes in the project. (Of course I’m overgeneralizing here. Classes like
IHttpModule, IHttpHandler and Global.asax would be instantiated first before the aspx
web form pages).

MVP (Supervising Controller) on the other hand, doesn’t mind for the View to take on
a bigger role. View is the first object instantiated in the execution pipeline, which then
responsible for passing any events that happens on itself to the Presenter.

The presenter then fetch the Models, and pass it back to the view for rendering.

What is the ‘page lifecycle’ of an ASP.NET MVC?

Following process are performed by ASP.Net MVC page:
1) App initialization
2) Routing
3) Instantiate and execute controller
4) Locate and invoke controller action
5) Instantiate and render view

How to call javascript function on the change of Dropdown List in ASP.NET
MVC?

Create a java-script function:
<script type="text/javascript">
            function selectedIndexChanged() {
            }
</script>

Call the function:

<%:Html.DropDownListFor(x => x.SelectedProduct,
new SelectList(Model.Products, "Value", "Text"),
"Please Select a product", new { id = "dropDown1",
onchange="selectedIndexChanged()" })%>

How route table is created in ASP.NET MVC?

When an MVC application first starts, the Application_Start() method is called. This
method, in turn, calls the RegisterRoutes() method. The RegisterRoutes() method
creates the route table.

How do you avoid XSS Vulnerabilities in ASP.NET MVC?

Use thesyntax in ASP.NET MVC instead of usingin .net framework 4.0.

Explain how to access Viewstate values of this page in the next page?

PreviousPage property is set to the page property of the nest page to access the
viewstate value of the page in the next page.
Page poster = this.PreviousPage;

Once that is done, a control can be found from the previous page and its state can
be read.
Label posterLabel = poster.findControl("myLabel");
 string lbl = posterLabel.Text;

How to create dynamic property with the help of viewbag in ASP.NET MVC?

PreviousPage property is set to the page property of the nest page to access the
viewstate value of the page in the next page.
Page poster = this.PreviousPage;

Once that is done, a control can be found from the previous page and its state can
be read.
Label posterLabel = poster.findControl("myLabel");
 string lbl = posterLabel.Text;

What is difference between Viewbag and Viewdata in ASP.NET MVC?

The basic difference between ViewData and ViewBag is that in ViewData instead
creating dynamic properties we use properties of Model to transport the Model data
in View and in ViewBag we can create dynamic properties without using Model data.

What is Routing?

A route is a URL pattern that is mapped to a handler. The handler can be a physical
file, such as an .aspx file in a Web Forms application. Routing module is
responsible for mapping incoming browser requests to particular MVC controller
actions.

For detailed Interview Questions refer my second post regarding MVC Interview
Questions.

Recomendados

Spring MVC Architecture Tutorial por
Spring MVC Architecture TutorialSpring MVC Architecture Tutorial
Spring MVC Architecture TutorialJava Success Point
2.3K visualizações7 slides
Spring Web MVC por
Spring Web MVCSpring Web MVC
Spring Web MVCzeeshanhanif
10.6K visualizações44 slides
Spring MVC 3.0 Framework por
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 FrameworkRavi Kant Soni (ravikantsoni03@gmail.com)
6.3K visualizações24 slides
Spring MVC Basics por
Spring MVC BasicsSpring MVC Basics
Spring MVC BasicsBozhidar Bozhanov
12.4K visualizações14 slides
ASP .net MVC por
ASP .net MVCASP .net MVC
ASP .net MVCDivya Sharma
5.4K visualizações26 slides
Spring 3.x - Spring MVC - Advanced topics por
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsGuy Nir
14.4K visualizações35 slides

Mais conteúdo relacionado

Mais procurados

Spring MVC por
Spring MVCSpring MVC
Spring MVCAaron Schram
2K visualizações28 slides
Introduction to Spring MVC por
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVCRichard Paul
6.4K visualizações18 slides
Spring MVC 3.0 Framework (sesson_2) por
Spring MVC 3.0 Framework (sesson_2)Spring MVC 3.0 Framework (sesson_2)
Spring MVC 3.0 Framework (sesson_2)Ravi Kant Soni (ravikantsoni03@gmail.com)
2.4K visualizações40 slides
Mvc architecture por
Mvc architectureMvc architecture
Mvc architectureSurbhi Panhalkar
44.4K visualizações28 slides
Spring 3.x - Spring MVC por
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVCGuy Nir
6.1K visualizações54 slides
Spring Portlet MVC por
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVCJohn Lewis
7.7K visualizações80 slides

Mais procurados(20)

Spring MVC por Aaron Schram
Spring MVCSpring MVC
Spring MVC
Aaron Schram2K visualizações
Introduction to Spring MVC por Richard Paul
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
Richard Paul6.4K visualizações
Mvc architecture por Surbhi Panhalkar
Mvc architectureMvc architecture
Mvc architecture
Surbhi Panhalkar44.4K visualizações
Spring 3.x - Spring MVC por Guy Nir
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy Nir6.1K visualizações
Spring Portlet MVC por John Lewis
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
John Lewis7.7K visualizações
MVC ppt presentation por Bhavin Shah
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
Bhavin Shah14K visualizações
Spring MVC por yuvalb
Spring MVCSpring MVC
Spring MVC
yuvalb2.4K visualizações
ASP .NET MVC por eldorina
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina1K visualizações
Jsf intro por vantinhkhuc
Jsf introJsf intro
Jsf intro
vantinhkhuc918 visualizações
Java Server Faces + Spring MVC Framework por Guo Albert
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
Guo Albert4.6K visualizações
Spring mvc por Hamid Ghorbani
Spring mvcSpring mvc
Spring mvc
Hamid Ghorbani865 visualizações
JSF Component Behaviors por Andy Schwartz
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
Andy Schwartz5.8K visualizações
MVC 4 por Vasilios Kuznos
MVC 4MVC 4
MVC 4
Vasilios Kuznos354 visualizações
CTTDNUG ASP.NET MVC por Barry Gervin
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin7.2K visualizações
MSDN - ASP.NET MVC por Maarten Balliauw
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
Maarten Balliauw6K visualizações
MVC por akshin
MVCMVC
MVC
akshin2K visualizações
A Complete Tour of JSF 2 por Jim Driscoll
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
Jim Driscoll7.1K visualizações
Design Patterns in ZK: Java MVVM as Model-View-Binder por Simon Massey
Design Patterns in ZK: Java MVVM as Model-View-BinderDesign Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-Binder
Simon Massey13.3K visualizações

Destaque

Presentazione Remote Angel SOS por
Presentazione Remote Angel SOSPresentazione Remote Angel SOS
Presentazione Remote Angel SOSmacnil
484 visualizações13 slides
Mini Evaluation (Can Designs) por
Mini Evaluation (Can Designs)Mini Evaluation (Can Designs)
Mini Evaluation (Can Designs)ChloeandRachel
286 visualizações7 slides
Persistence por
PersistencePersistence
PersistenceAnish Thomas Alex
296 visualizações11 slides
4087 chapter 08 8ed part2 por
4087 chapter 08 8ed part24087 chapter 08 8ed part2
4087 chapter 08 8ed part2winegron
211 visualizações33 slides
Sabetta 2 por
Sabetta 2Sabetta 2
Sabetta 2milka562
21.7K visualizações40 slides
Subculture por
SubcultureSubculture
SubcultureDima69
501 visualizações11 slides

Destaque(19)

Presentazione Remote Angel SOS por macnil
Presentazione Remote Angel SOSPresentazione Remote Angel SOS
Presentazione Remote Angel SOS
macnil484 visualizações
Mini Evaluation (Can Designs) por ChloeandRachel
Mini Evaluation (Can Designs)Mini Evaluation (Can Designs)
Mini Evaluation (Can Designs)
ChloeandRachel286 visualizações
4087 chapter 08 8ed part2 por winegron
4087 chapter 08 8ed part24087 chapter 08 8ed part2
4087 chapter 08 8ed part2
winegron211 visualizações
Sabetta 2 por milka562
Sabetta 2Sabetta 2
Sabetta 2
milka56221.7K visualizações
Subculture por Dima69
SubcultureSubculture
Subculture
Dima69501 visualizações
IRN BRU Final Evaluation por ChloeandRachel
IRN BRU Final EvaluationIRN BRU Final Evaluation
IRN BRU Final Evaluation
ChloeandRachel316 visualizações
Gamer street20 por Gamerstreet
Gamer street20Gamer street20
Gamer street20
Gamerstreet376 visualizações
Photo album por hannahgcse
Photo albumPhoto album
Photo album
hannahgcse176 visualizações
Ask the XPages Experts por Teamstudio
Ask the XPages ExpertsAsk the XPages Experts
Ask the XPages Experts
Teamstudio1.2K visualizações
Principle internet question por anandhsaran
Principle internet questionPrinciple internet question
Principle internet question
anandhsaran2.9K visualizações
Week2 pp sociology. por Stephen Lord
Week2 pp sociology.Week2 pp sociology.
Week2 pp sociology.
Stephen Lord207 visualizações
5 course por Galina Perova
5 course5 course
5 course
Galina Perova439 visualizações
1000n policeheart 1091 - women helpline for emergency rescue por Shakun Chauhan
1000n policeheart 1091 - women helpline for emergency rescue1000n policeheart 1091 - women helpline for emergency rescue
1000n policeheart 1091 - women helpline for emergency rescue
Shakun Chauhan487 visualizações
Cooperative learning por adhwaa
Cooperative learning Cooperative learning
Cooperative learning
adhwaa179 visualizações
интернет por kristina54
интернетинтернет
интернет
kristina54207 visualizações
Sejarah internet por Madiyantosetiyon
Sejarah internetSejarah internet
Sejarah internet
Madiyantosetiyon206 visualizações
внимание! внимание! por kroc2005
внимание! внимание!внимание! внимание!
внимание! внимание!
kroc2005206 visualizações
Tempo November 2014 por Tempoplanet
Tempo November 2014Tempo November 2014
Tempo November 2014
Tempoplanet1.9K visualizações

Similar a Jinal desai .net

Asp.net mvc por
Asp.net mvcAsp.net mvc
Asp.net mvcTaranjeet Singh
248 visualizações21 slides
Session 1 por
Session 1Session 1
Session 1Asif Atick
521 visualizações10 slides
Mvc interview questions – deep dive jinal desai por
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desaijinaldesailive
12.7K visualizações4 slides
MVC 6 Introduction por
MVC 6 IntroductionMVC 6 Introduction
MVC 6 IntroductionSudhakar Sharma
1.5K visualizações45 slides
ASP.NET MVC as the next step in web development por
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentVolodymyr Voytyshyn
2.7K visualizações43 slides
Mvc por
MvcMvc
Mvcabhigad
579 visualizações14 slides

Similar a Jinal desai .net(20)

Asp.net mvc por Taranjeet Singh
Asp.net mvcAsp.net mvc
Asp.net mvc
Taranjeet Singh248 visualizações
Session 1 por Asif Atick
Session 1Session 1
Session 1
Asif Atick521 visualizações
Mvc interview questions – deep dive jinal desai por jinaldesailive
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
jinaldesailive12.7K visualizações
MVC 6 Introduction por Sudhakar Sharma
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
Sudhakar Sharma1.5K visualizações
ASP.NET MVC as the next step in web development por Volodymyr Voytyshyn
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web development
Volodymyr Voytyshyn2.7K visualizações
Mvc por abhigad
MvcMvc
Mvc
abhigad579 visualizações
Spring Framework-II por People Strategists
Spring Framework-IISpring Framework-II
Spring Framework-II
People Strategists1.3K visualizações
Spring MVC introduction HVA por Peter Maas
Spring MVC introduction HVASpring MVC introduction HVA
Spring MVC introduction HVA
Peter Maas1.1K visualizações
Introduction To Mvc por Volkan Uzun
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
Volkan Uzun2.4K visualizações
Head first asp.net mvc 2.0 rtt por Lanvige Jiang
Head first asp.net mvc 2.0 rttHead first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rtt
Lanvige Jiang3.6K visualizações
ASP.NET MVC Presentation por ivpol
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
ivpol23.6K visualizações
Mvc Brief Overview por rainynovember12
Mvc Brief OverviewMvc Brief Overview
Mvc Brief Overview
rainynovember121.3K visualizações
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web... por SoftServe
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe1.2K visualizações
Asp.Net MVC Intro por Stefano Paluello
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
Stefano Paluello7.9K visualizações
MVC & backbone.js por Mohammed Arif
MVC & backbone.jsMVC & backbone.js
MVC & backbone.js
Mohammed Arif4K visualizações
Asp.net,mvc por Prashant Kumar
Asp.net,mvcAsp.net,mvc
Asp.net,mvc
Prashant Kumar175 visualizações
springmvc-150923124312-lva1-app6892 por Tuna Tore
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore408 visualizações
Spring mvc por nagarajupatangay
Spring mvcSpring mvc
Spring mvc
nagarajupatangay718 visualizações
ASP.Net | Sabin Saleem por SaBin SaleEm
ASP.Net | Sabin SaleemASP.Net | Sabin Saleem
ASP.Net | Sabin Saleem
SaBin SaleEm70 visualizações
Struts(mrsurwar) ppt por mrsurwar
Struts(mrsurwar) pptStruts(mrsurwar) ppt
Struts(mrsurwar) ppt
mrsurwar1.9K visualizações

Jinal desai .net

  • 1. Articles from Jinal Desai .NET ASP.NET MVC 3 Interview Questions 2011-10-21 15:10:50 Jinal Desai What is MVC? MVC is a framework methodology that divides an application’s implementation into three component roles: models, views, and controllers. “Models” in a MVC based application are the components of the application that are responsible for maintaining state. Often this state is persisted inside a database (for example: we might have a Product class that is used to represent order data from the Products table inside SQL). “Views” in a MVC based application are the components responsible for displaying the application’s user interface. Typically this UI is created off of the model data (for example: we might create an Product “Edit” view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object). “Controllers” in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVC application the view is only about displaying information – it is the controller that handles and responds to user input and interaction. Which are the advantages of using MVC Framework? MVC is one of the most used architecture pattern in ASP.NET and this is one of those ASP.NET interview question to test that do you really understand the importance of model view controller. 1. It provides a clean separation of concerns between UI and model. 2. UI can be unit test thus automating UI testing. 3. Better reuse of views and model. You can have multiple views which can point to the same model and also vice versa. 4. Code is better organized. What is Razor View Engine? Razor view engine is a new view engine created with ASP.Net MVC model using specially designed Razor parser to render the HTML out of dynamic server side code. It allows us to write Compact, Expressive, Clean and Fluid code with new syntaxes to include server side code in to HTML. What is namespace of asp.net mvc? ASP.NET MVC namespaces and classes are located in the System.Web.Mvc assembly. System.Web.Mvc namespace Contains classes and interfaces that support the MVC pattern for ASP.NET Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial views, and model binders. System.Web.Mvc.Ajax namespace Contains classes that support Ajax scripts in an ASP.NET MVC application. The namespace includes support for Ajax scripts and Ajax option settings. System.Web.Mvc.Async namespace Contains classes and interfaces that support asynchronous actions in an ASP.NET MVC application System.Web.Mvc.Html namespace
  • 2. Contains classes that help render HTML controls in an MVC application. The namespace includes classes that support forms, input controls, links, partial views, and validation. How to identify AJAX request with C# in MVC.NET? The solution is in depended from MVC.NET framework and universal across server- side technologies. Most modern AJAX applications utilize XmlHTTPRequest to send async request to the server. Such requests will have distinct request header: X-Requested-With = XMLHTTPREQUEST MVC.NET provides helper function to check for ajax requests which internally inspects X-Requested-With request header to set IsAjax flag. HelperPage.IsAjax Property Gets a value that indicates whether Ajax is being used during the request of the Web page. Namespace: System.Web.WebPages Assembly: System.Web.WebPages.dll However, same can be achieved by checking requests header directly: Request["X-Requested-With"] == “XmlHttpRequest” What is Repository Pattern in ASP.NET MVC? Repository pattern is usefult for decoupling entity operations form presentation, which allows easy mocking and unit testing. “The Repository will delegate to the appropriate infrastructure services to get the job done. Encapsulating in the mechanisms of storage, retrieval and query is the most basic feature of a Repository implementation” “Most common queries should also be hard coded to the Repositories as methods.” Which MVC.NET to implement repository pattern Controller would have 2 constructors on parameterless for framework to call, and the second one which takes repository as an input: class myController: Controller { private IMyRepository repository; // overloaded constructor public myController(IMyRepository repository) { this.repository = repository; }
  • 3. // default constructor for framework to call public myController() { //concreate implementation myController(new someRepository()); } ... public ActionResult Load() { // loading data from repository var myData = repository.Load(); } } What is difference between MVC(Model-View-Controller) and MVP(Model- View-Presenter)? The main difference between the two is how the manager (controller/presenter) sits in the overall architecture. All requests goes first to the Controller MVC pattern puts the controller as the main ‘guy’ in charge for running the show. All application request comes through straight to the controller, and it will decide what to do with the request. Giving this level of authority to the controller isn’t an easy task in most cases. Users interaction in an application happen most of the time on the View. Thus to adopt MVC pattern in a web application, for example, the url need to become a way of instantiating a specific controller, rather than ‘simply’ finding the right View (webform/ html page) to render out. Every requests need to trigger the instantiation of a controller which will eventually produce a response to the user. This is the reason why it’s alot more difficult to implement pure MVC using Asp.Net Webform. The Url routing system in Asp.Net webform by default is tied in to the server filesystem or IIS virtual directory structure. Each of these aspx files are essentially Views which will always get called and instantiated first before any other classes in the project. (Of course I’m overgeneralizing here. Classes like IHttpModule, IHttpHandler and Global.asax would be instantiated first before the aspx web form pages). MVP (Supervising Controller) on the other hand, doesn’t mind for the View to take on a bigger role. View is the first object instantiated in the execution pipeline, which then responsible for passing any events that happens on itself to the Presenter. The presenter then fetch the Models, and pass it back to the view for rendering. What is the ‘page lifecycle’ of an ASP.NET MVC? Following process are performed by ASP.Net MVC page: 1) App initialization 2) Routing 3) Instantiate and execute controller 4) Locate and invoke controller action 5) Instantiate and render view How to call javascript function on the change of Dropdown List in ASP.NET MVC? Create a java-script function:
  • 4. <script type="text/javascript"> function selectedIndexChanged() { } </script> Call the function: <%:Html.DropDownListFor(x => x.SelectedProduct, new SelectList(Model.Products, "Value", "Text"), "Please Select a product", new { id = "dropDown1", onchange="selectedIndexChanged()" })%> How route table is created in ASP.NET MVC? When an MVC application first starts, the Application_Start() method is called. This method, in turn, calls the RegisterRoutes() method. The RegisterRoutes() method creates the route table. How do you avoid XSS Vulnerabilities in ASP.NET MVC? Use thesyntax in ASP.NET MVC instead of usingin .net framework 4.0. Explain how to access Viewstate values of this page in the next page? PreviousPage property is set to the page property of the nest page to access the viewstate value of the page in the next page. Page poster = this.PreviousPage; Once that is done, a control can be found from the previous page and its state can be read. Label posterLabel = poster.findControl("myLabel"); string lbl = posterLabel.Text; How to create dynamic property with the help of viewbag in ASP.NET MVC? PreviousPage property is set to the page property of the nest page to access the viewstate value of the page in the next page. Page poster = this.PreviousPage; Once that is done, a control can be found from the previous page and its state can be read. Label posterLabel = poster.findControl("myLabel"); string lbl = posterLabel.Text; What is difference between Viewbag and Viewdata in ASP.NET MVC? The basic difference between ViewData and ViewBag is that in ViewData instead creating dynamic properties we use properties of Model to transport the Model data in View and in ViewBag we can create dynamic properties without using Model data. What is Routing? A route is a URL pattern that is mapped to a handler. The handler can be a physical file, such as an .aspx file in a Web Forms application. Routing module is responsible for mapping incoming browser requests to particular MVC controller actions. For detailed Interview Questions refer my second post regarding MVC Interview Questions.