Asp Net Mvc Routing Interview Questions

17) What is the difference between Temp data, View data, and View Bag?

  • Temp data: It helps to maintain data when you shift from one controller to another controller.
  • View data: It helps to maintain data when you move from controller to view.
  • View Bag: It’s a dynamic wrapper around view data.
  • 19) How can you implement Ajax in MVC?

    In MVC, Ajax can be implemented in two ways

    3 How can we done Custom Error Page in MVC?


    The HandleErrorAttribute allows you to use a custom page for this error. First you need to update your web.config file to allow your application to handle custom errors.

    Then, your action method needs to be marked with the atttribute.

    By calling the ThrowException action, this would then redirect the user to the default error page. In our case though, we want to use a custom error page and redirect the user there instead.So, lets create our new custom view page.

    Next, we simply need to update the HandleErrorAttribute on the action method.

    Learn more here – Custom Error Page in ASP.NET MVC

    18) What is a partial view in MVC?

    Partial view in MVC renders a portion of view content. It is helpful in reducing code duplication. In simple terms, the partial view allows rendering a view within the parent view.

    23) What are the types of results in MVC?

    In MVC, there are twelve types of results in where “ActionResult” class is the main class while the 11 are their sub-types:

  • ViewResult
  • PartialViewResult
  • EmptyResult
  • RedirectResult
  • RedirectToRouteResult
  • JsonResult
  • JavaScriptResult
  • ContentResult
  • FileContentResult
  • FileStreamResult
  • FilePathResult
  • 33) What is the difference between 3-tier Architecture and MVC Architecture?

    Here is a difference between 3-tier Architecture and MVC Architecture:

    Parameter 3-Tier Architecture MVC Architecture
    Communication This type of architecture pattern never communicates directly with the data layer. All layers communicate directly using triangle topology.
    Usage 3-tier: widely used in web applications where the client, data tiers, and middleware run on physically separate platforms. Generally used on applications that run on a single graphical workstation.

    3) Name the assembly to define MVC

    The MVC Framework is defined in System.Web.Mvc assembly.

    In the ASP.NET Core project, which basic folders use the MVC template without Areas?

    The following folders use the MVC template without Areas:

  • Controllers- default folder for application controllers
  • wwwroot- publicly accessible folder of a site containing subfolders of static files
  • Views- folder containing a folder for every controller and a particular folder shared for views used by controllers or multiple views.Â
  • 1 How do you implement Forms authentication in MVC?


    Authentication is giving access to the user for a specific service by verifying his/her identity using his/her credentials like username and password or email and password. It assures that the correct user is authenticated or logged in for a specific service and the right service has been provided to the specific user based on their role that is nothing but authorization.

    ASP.NET forms authentication occurs after IIS authentication is completed. You can configure forms authentication by using forms element with in web.config file of your application. The default attribute values for forms authentication are shown below,

    The FormsAuthentication class creates the authentication cookie automatically when SetAuthCookie() or RedirectFromLoginPage() methods are called. The value of authentication cookie contains a string representation of the encrypted and signed FormsAuthenticationTicket object.

    Learn more here – Form Authentication in MVC 5: Part 1


    From ASP.Net MVC 2.0 Microsoft provided a new feature in MVC applications, Areas. Areas are just a way to divide or “isolate” the modules of large applications in multiple or separated MVC. like,

    When you add an area to a project, a route for the area is defined in an AreaRegistration file. The route sends requests to the area based on the request URL. To register routes for areas, you add code to theGlobal.asax file that can automatically find the area routes in the AreaRegistration file.

    Benefits of Area in MVC

  • Allows us to organize models, views and controllers into separate functional sections of the application, such as administration, billing, customer support and much more.
  • Easy to integrate with other Areas created by another.
  • Easy for unit testing.
  • Learn more here – What Are Areas in ASP.Net MVC – Part 6

    What is Routing? Explain attribute routing in ASP.NET Core?

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *