10.0.x
541 201 9965 Email Website
Contents
:
Search:

Home > Development Notes > MVC In Adnsf

MVC In Adnsf

MVC in AspDotNetStorefront

AspDotNetStorefront is an Asp.Net MVC application. This page steps through some of the differences between the way that AspDotNetStorefront is structured compared to a typical ASP.NET MVC application. There are a lot of amazing resources about building .Net MVC applications, so we're not going to cover .Net MVC in depth here. Here is a great starting point on MVC: http://www.asp.net/mvc/overview

Views

You'll find AspDotNetStorefront's razor views in the typical location for an MVC project, in the /Views folder at the root of the website. These are your default views.

Views contain the main content areas for each page of your website. In general, you can think of a view as an individual page on the front-end of your site. For example you can find the view responsible for your home page content at /Views/Home/Index.cshtml.

One thing you won't find in the root /Views folder is the _Layout.cshtml file. This is because the layout file is in the "Skin."

Partial views

Views can also be used as partial views or child actions. Partial views and child actions enable you to nest views within each other to output a section of the page. In AspDotNetStorefront, we follow a convention using underscores to indicate that a view is used as a partial view. For example the /Views/Shared/_Search.chstml file renders the search box.

Skins

Skins are not a built-in ASP.NET MVC concept. Skins are unique to AspDotNetStorefront. The Skin contains the look and feel of your website, where you can affect the header and footer of every page as well as the styles used throughout the site. If you are a web designer, this is where you'll spend most of your time modifying HTML and CSS. Skins are found in the /Skins folder. Each folder found in the /Skins folder represents a unique skin. Below is the default skin installed in AspDotNetStorefront.

In the skin you'll find CSS, Images, Views, and XmlPackages. Let's focus on the views folder, for now.

In the /Skins/{SkinName}/Views/Shared folder you'll find the main layout for the site (_Layout.cshtml). This file contains the HTML used to make up the skin. The _Layout page view pulls in the _Head, _BodyOpen, and _BodyClose partials to output sub-sections of the main layout.

Overriding views from the skin

It's important to understand that you can place any view that you find in the root /Views folder into the Skins/{SkinName}/Views folder and it will override the corresponding default view. For example, to override the home page view for a given skin you can take the /Views/Home/Index.cshtml view and copy it to /Skins/{SkinName}/Views/Home/Index.cshtml. If you do, the skin level view will override the root level view. This can be helpful in a few different scenarios.

  1. If you want to maintain in one location your modified views so you know which files have been modified. This is helpful when you upgrade your website to a later version.
  2. If you have several stores configured, each with their own skin, and you want one skin to behave differently on a given view than the other stores which share the default view.

Controllers

The controllers can be found in the AspDotNetStorefront.Controllers project. If you want to modify how controllers behave, you need to need to make sure that you own source code. Controllers do not get deployed to the webserver. Instead, they are compiled into the AspDotNetStorefront.Controllers.dll.

Models

AspDotNetStorefront uses the viewmodel strategy to pass data down to the view to render. All viewmodels are located in the AspDotNetStorefront.Models project.

Viewmodels are simple classes that contain all the data required by the view. In general, viewmodels are passed from the controller down do the view and then back up again on pages that post data back to the server.

Routing

Routing is how you map a given URL to a given controller. The logic for routing in AspDotNetStorefront is in the AspDotNetStorefront.Application project. For more information about routing, refer to http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/asp-net-mvc-routing-overview-cs.



Actions
Print This Article
Bookmark
Email This Article
Previous Article
Next Article

Was this page helpful?YesNo