Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, 5 August 2014

Action result types one of the common question in interview

ActionResult is an abstract class so you can never return it. You always return a derived class such as ViewResult, RedirectResult, JsonResult, FileResult, JavaScriptResult, ContentResult depending on what do you want your controller action to do (render a view, redirect to another url, return JSON formatted data, download a file, ...). As far as the signature of your action method is concerned I would recommend you always having ActionResult as return type.



ViewResult (View) --Renders a view as a Web page.

PartialViewResult  (PartialView)--Renders a partial view,which defines a section 

of view that can be rendered inside another view.

RedirectResult (Redirect)--Redirects to another action method by using its URL.


RedirectToRouteResult (RedirectToAction/RedirectToRoute)--Redirects to another action method.


ContentResult (Content)--Returns a user-defined 

content type.

JsonResult (Json)--Returns a serialized 

JSON object.

JavaScriptResult (JavaScript)--Returns a script that can

Be executed on the client.

FileResult (File)--Returns binary output to

 write to the response.


EmptyResult(None)--Represents a return value
that is used if the action
 method must return a
 null result (void).



Difference Between Asp.Net and MVC Web forms



Asp.Net Web Form follow a traditional event driven development model.
Asp.Net MVC is a lightweight and follow MVC (Model, View, Controller) pattern based development model.
Asp.Net Web Form has server controls
Asp.Net MVC has html helpers.
Asp.Net Web Form has state management (like as view state, session) techniques.
Asp.Net MVC has no automatic state management techniques.
Asp.Net Web Form has file-based URLs means file name exist in the URLs must have its physically existence.
Asp.Net MVC has route-based URLs means URLs are divided into controllers and actions and moreover it is based on controller not on physical file
Asp.Net Web Form follows Web Forms Syntax
Asp.Net MVC follow customizable syntax (Razor as default)
In Asp.Net Web Form, Web Forms(ASPX) i.e. views are tightly coupled to Code behind(ASPX.CS) i.e. logic.
In Asp.Net MVC, Views and logic are kept separately.
Asp.Net Web Form has Master Pages for consistent look and feels.
Asp.Net MVC has Layouts for consistent look and feels.
Asp.Net Web Form has User Controls for code re-usability.
Asp.Net MVC has Partial Views for code re-usability.
Asp.Net Web Form has built-in data controls and best for rapid development with powerful data access.
Asp.Net MVC is lightweight, provide full control over markup and support many features that allow fast & agile development. Hence it is best for developing interactive web application with latest web standards.