Professional Documents
Culture Documents
MVC-Day 01
1) What is MVC?
MVC is a pattern which is used to split the application's implementation logic into three
components: models, views, and controllers.
MVC-Day-02
4) Is it possible to combine ASP.NET webforms and ASP.MVC and develop a single web
application?
Yes, it is possible to combine ASP.NET webforms and ASP.MVC and develop a single web
application.
5)What is the greatest advantage of using asp.net mvc over asp.net webforms?
It is difficult to unit test UI with webforms, where views in mvc can be very easily unit tested
8) ASP.NET MVC application, makes use of settings at 2 places for routing to work
correctly. What are these 2 places?
1. Web.Config File : ASP.NET routing has to be enabled here.
2. Global.asax File : The Route table is created in the application Start event handler, of the
Global.asax file.
15) Can a view be shared across multiple controllers? If Yes, How we can do that?
Yes, we can share a view across multiple controllers. We can put the view in the “Shared” folder.
When we create a new MVC Project we can see the Layout page will be added in the shared
folder, which is because it is used by multiple child pages.
MVC-Day-03
1 ) Can we add constraints to the route? If yes, explain how we can do it?
Yes we can add constraints to route in following ways –
Using Regular Expressions
Using object which implements interface - IRouteConstraint.
}
Solution :
Public ActionResult MyTestAction(string submit) //submit will have value either “MySave” or
“MyEdit”
{
// Write code here
23) Explain what is the difference between View and Partial View?
MVC-Day-04
2) If I have multiple filters impleted, what is the order in which these filters get executed?
1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters
6) What are the levels at which filters can be applied in an asp.net mvc application?
1. Action Method
2. Controller
3. Application
10) What symbol would you use to denote, the start of a code block in razor views?
@
11) What symbol would you use to denote, the start of a code block in aspx views?
<%= %>
12) In razor syntax, what is the escape sequence character for @ symbol?
The escape sequence character for @ symbol, is another @ symbol
13) When using razor views, do you have to take any special steps to proctect your asp.net
mvc application from cross site scripting (XSS) attacks?
No, by default content emitted using a @ block is automatically HTML encoded to protect from
cross site scripting (XSS) attacks.
14) When using aspx view engine, to have a consistent look and feel, across all pages of the
application, we can make use of asp.net master pages. What is asp.net master pages
equivalent, when using razor views?
To have a consistent look and feel when using razor views, we can make use of layout pages.
Layout pages, reside in the shared folder, and are named as _Layout.cshtml
Required - This attribute makes the property of model mandatory for user.
StringLength - The StringLength attribute specifies the maximum length of string that is
acceptable.
RegularExpression - Regular expressions are an efficient and terse means to enforce the
shape and contents of a string value.
Range - The Range attribute specified the minimum and maximum constraints for a
numerical value.
Compare - The compare attribute ensures two properties on a model object have the
same value.
Display - The Display attribute sets the friendly name for a model property.
ScaffoldColumn - The scaffoldColumn attribute hides a property from HTML helper
such as EditorForModel and DisplayForModel.
MaxLength - MaxLength Attribute ensures the length of the string entered is according
to the specified value.
DataType - The DataType attribute enables you to provide the run time with information
about the specific purpose of a property.
UIHint - The UIHint attribute as the name itself suggest gives the Asp.net MVC run time
the name of a template to use when rendering output with the templated helpers like
(DisplayFor and EditorFor).
HiddenInput - The property that has HiddenInput defined on it will be rendered as input
type hidden on form.
Entity Framework is an ORM from Microsoft that will enable the developers to work with
domain specific objects, which eliminates the extra code being written in the data access layer.
ADO.NET is faster. "Entity Framework will be around the ADO.NET, which means
ADO.NET Entity Framework
We need to write so much code Easy to use. As an Entity Framework will talk to database
to talk to database. without much code involved.
Add New Item -> ADO.NET Entity Data Model, which generates file with .edmx extension.
.edmx file is a XML file and it has Conceptual Model, Storage Model and Mapping details i.e,
Conceptual Models are the model classes which contain the relationships. These are independent
of the database design.
Storage Models are our database design models, which contains database tables, views, stored
procs and keys with relationships.
The Mapping will have the information on how the Conceptual Models are mapped to Storage
Models.
MVC-Day-01
1.Create MVC Application Student Portal With Two Action Methods for showing Login Page
And Register Page(Mode l+ View)
2.Display Student details from Controller to View Using ViewBag And ViewData(Name
,Mobile, Age, Dept)
3.Display Student Details using Model Class(Model+View + Controller)
MVC -DAY-02
1. Create Employee Salary Calculation Application with Show Details, Salary Calculation
Action Methods using model,View and Controller
2. Design View Using HTML Contols to Get Employee details from Runtime
3. Design View Using HTML Helper Class Methods to Get Employee details from Runtime
MVC-Day-03
1. Create application to get Number from runtime and perform Mathematical Operations
a. Oddoreven
b. Prime or Not
c. Perfect Number
Choose option and click Submit button provide corresponding output.
2. Create application to get String from runtime and perform Mathematical Operations
a. S
b. Prime or Not
c. Perfect Number
Choose option and click Submit button provide corresponding output.