Tech Support Websites

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Thursday, 23 May 2013

ASP.NET MVC 4 Questions and Answers

Posted on 09:50 by Unknown

Q) What is the name of the unit testing Framework that is available with a ASP.NET MVC 4 Project in Visual Studio?
MSTest

Q) Which code will execute before any of the Controllers are run?
The code within Application_Start() in global.asax will start executing before any of the Controllers run

Q) Which HTTP status code does a RedirectPermanent ActionResult return?
RedirectPermanent returns a 301 status code

Q) How does ASP.NET know how to deliver a request like http://localhost/home/about?
Routing engine (not tied to ASP.NET MVC Framework) directs requests to Controllers. The route map is defined in global.asax

Q) What is NuGet?
It is a Package Manager for .NET applications. NuGet can be used to install, update and configure software (DLLs) in the form of Packages, for use in a Visual Studio project. This way you don't have to download it or track dependencies. NuGet understands package dependencies & will fetch dependent packages as well.

Q) Where do NuGet Packages come from?
1. NuGet official feed of packages (from nuget.org)
2. Your local repository
3. Your network share
    Q) Where do NuGet Packages go?
    When you install a NuGet package it goes into the Packages folder within the Visual Studio Solution from where you requested. It stores the Package on a per solution basis, not putting in the GAC or Program Files. It is local to that Solution. This makes it easy to update and put a package under version control. The Packages.config file within a Visual Studio solution lists all the Packages that have been installed for the project

    Q) What is in a NuGet Package?
    A *.nupkg is a zip file that contains:
    Metadata - dependencies, URLs, version numbers are specified in a XML file
    Binaries - assemblies (DLLs)
    Other content - scripts, images, code blocks

    Q) Can NuGet commands be executed from the command line?
    Yes, using PowerShell. To view the list of commands, open the Package Manager Console in Visual Studio (View > Other Windows > Package Manager Console) & type help package

    Q) Which is the namespace you have to include when you're using DataAnnotations?
    System.ComponentModel.DataAnnotations

    Q) Where does the Razor Layout View reside?
    The Layout View in Razor (the equivalent of Master Page in ASP.NET WebForms) resides in the Shared folder under the Views folder. It is represented by the _Layout.cshtml file

    Q) How does MVC runtime know that it has to use _Layout.cshtml?  
    Q) What is the significance of the _ViewStart.cshtml file?
    _ViewStart.cshtml resides in the root of the Views folder. It contains a code block containing a Layout property set to the the _Layout.cshtml file. It is a Razor convention that anything inside  _ViewStart.cshtml will execute before a View does. _ViewStart.cshtml applies to all Views. It can be overriden on a per View basis.

    Q) What does a Razor Layout page contain?

    Razor Layout pages are HTML files that define a Body and additional sections by using the following instructions:
    @RenderBody(): Renders the content of a page that is not within any named sections.
    @RenderSection("mySectionName"): Renders the content of the section within the given name. Sections are mandatory by default, so each page linked to the template will have to declare them.
    @RenderSection("mySectionName", optional:true): Renders the content of an optional section. The pages that are linked to the template can omit the definition of an optional section.

    Q) How to ignore the default Layout view?
    To avoid using the default Layout page, set Layout property to null

    Q) Can you build your own custom HTML Helpers?
    Yes, you can build your custom HTML Helpers

    Q) What does the Razor WebGrid Helper do?
    The WebGrid Helper renders an HTML table that displays data from the model or from a database. It
    supports data formatting, paging and sorting.

    It generates a collection of Columns and parameters within the given data source, which is rendered as an
    HTML table that can be accessed after the grid is generated.

    Q) What does @: in Razor represent?
    @: makes Razor interpret a string as literal text

    Q) What are the project templates presented to you by Visual Studio when you start a ASP.NET MVC 4 Project?
    Empty - empty ASP.NET MVC 4 Project
    Basic - basic ASP.NET MVC 4 Project
    Internet Application - a default ASP.NET MVC 4 Project with an account controller that uses Forms Authentication
    Intranet Application - a default ASP.NET MVC 4 Project with an account controller that uses Windows Authentication
    Mobile Application - an ASP.NET MVC 4 Project for mobile devices with an account controller that uses Forms Authentication
    Web API - a ASP.NET Web API Project

    Q) What are Action Filters? Give examples.
    Action Filters are the components that are used to apply cross-cutting logic i.e logic that has to be executed across multiple controller actions so that you don’t have to duplicate code inside of individual controllers.

    Action Filters supply pre and post processing logic to a controller action and its result

    Global filters are applied at application startup. 

    Examples:
    OutputCache - caches the output of a Controller
    Authorize - restricts an Action to authorized users or roles
    ValidateAntiForgeryToken - helps prevent cross site request forgeries
    HandleError - can specify a view to render in the event of an unhandled exception.

    work in progress...

    Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
    Posted in ASP.NET-MVC | No comments
    Newer Post Older Post Home

    0 comments:

    Post a Comment

    Subscribe to: Post Comments (Atom)

    Popular Posts

    • Windows 8 keyboard shortcuts
      Win + X   - context menu to access common features like Control Panel, Task Manager, File Explorer, Programs & Features, Run, Search etc...
    • What is the difference between Browser Mode & Document Mode in IE
      If you're a web developer and your job actively involves building web pages that work the same in all browsers including the last three ...
    • My 30-day personal project - watch 100 hours of Pluralsight videos
      Inspired by Matt Cutts' 30-day challenges , I plan to watch 100 hours of Pluralsight online videos to get up-to-date with current ...
    • Archive tweets & favorites with Google Reader
      There are numerous ways to archive tweets but rather than use yet another tool, I prefer using Google Reader to preserve the tweets I mark ...
    • TWIL - Week #3
      This Week I Learned: New Azure VM Image Templates include SQL Server, BizTalk Server, and SharePoint Server (2013?) images . This can be han...
    • Dashboard-like info with Browser tabs, Windows 7 Taskbar tabs
      Browser tabs & Windows 7 Taskbar tabs are turning self-aware.  This is how my browser looked the other day: I had the summary of all tha...
    • The State Of HTML5 Video
      Key points from the  The State Of HTML5 Video  report by LongTailVideo (last updated on April 19, 2012): 75% of the desktop & mobile bro...
    • Azure in Pictures - overview of Windows Azure Features, Services and Common Uses
      Download the Windows Azure Poster in PDF format (1.1MB)
    • Indian comparison shopping sites
      Did you know, India has 120 million Internet users & the Indian e-commerce market is worth $7 billion ?  Travel accounts for over 80 per...
    • Things to consider before settling on a JavaScript Library or jQuery plugin for your project
      In the article, Which JavaScript Library Should I Pick? , Pamela Fox has listed some practical points to consider before you settle on a Jav...

    Categories

    • AJAX
    • Android
    • APIs
    • App
    • ASP
    • ASP.NET
    • ASP.NET-MVC
    • Azure
    • Azure SQL Database
    • AzureInPictures
    • Bing
    • Book Review
    • Bookmarklet
    • Browsers
    • C#
    • chart
    • Chrome
    • Cloud
    • CSS
    • CSS3
    • DidYouKnow
    • E-Commerce
    • Excel
    • FB
    • Fiddler
    • Firefox
    • Gadgets
    • GeoLocation
    • GMail
    • Google
    • Google Docs
    • Google Reader
    • Health
    • Hotmail
    • HOWTO
    • HTML
    • HTML/CSS
    • HTML5
    • Humor
    • Hyderabad
    • IE
    • IIS
    • India
    • Internet
    • IT
    • Javascript
    • jQuery
    • JSON
    • JSONP
    • Laptop
    • Learning Resources
    • Lists
    • Map
    • Metrics
    • Microsoft
    • miscellaneous
    • Mobile
    • NAPA
    • Office365
    • Opera
    • PDF
    • Performance
    • Personal
    • PHP
    • PM
    • PowerShell
    • Privacy
    • Programming
    • Rant
    • Safari
    • Science
    • Search Engines
    • SearchEngines
    • Security
    • SEO
    • Sharepoint
    • SharePoint2013
    • Silverlight
    • Software Engineering
    • Solutions
    • SQL Azure
    • SQL Server
    • TFS
    • Tip
    • Tips
    • Tools
    • Tools/Utilities
    • Trivia
    • TWIL
    • Twitter
    • UX
    • VM
    • VS.NET
    • VS2010
    • VS2012
    • WCF
    • WebApps
    • Websites
    • WF
    • Windows Phone
    • Windows7
    • Windows8
    • Word
    • WP7
    • WPF

    Blog Archive

    • ▼  2013 (112)
      • ►  October (16)
      • ►  September (14)
      • ►  August (8)
      • ►  July (8)
      • ►  June (13)
      • ▼  May (12)
        • NDepend - a powerful .NET code analysis tool
        • TWIL - Week #8
        • ASP.NET MVC 4 Questions and Answers
        • Book Review: Instant jQuery 2.0 Table Manipulation...
        • TWIL - Week #7
        • Learn about Chrome DevTools at Code School
        • Book Review: Instant jQuery Drag-and-Drop Grids Ho...
        • Glossary of keywords used in Microsoft Technologies
        • TWIL - Week #6
        • HOW TO view a .NET DLL's dependencies
        • TWIL - Week #5
        • HOW TO easily autofit or scale wide images so that...
      • ►  April (12)
      • ►  March (8)
      • ►  February (15)
      • ►  January (6)
    • ►  2012 (127)
      • ►  December (11)
      • ►  November (14)
      • ►  October (13)
      • ►  September (14)
      • ►  August (16)
      • ►  July (16)
      • ►  June (6)
      • ►  May (5)
      • ►  April (11)
      • ►  March (12)
      • ►  February (7)
      • ►  January (2)
    • ►  2011 (98)
      • ►  December (5)
      • ►  November (2)
      • ►  October (5)
      • ►  September (7)
      • ►  August (7)
      • ►  July (15)
      • ►  June (10)
      • ►  May (7)
      • ►  April (8)
      • ►  March (10)
      • ►  February (11)
      • ►  January (11)
    • ►  2010 (163)
      • ►  December (14)
      • ►  November (19)
      • ►  October (19)
      • ►  September (15)
      • ►  August (18)
      • ►  July (17)
      • ►  June (20)
      • ►  May (17)
      • ►  April (19)
      • ►  March (5)
    Powered by Blogger.

    About Me

    Unknown
    View my complete profile