Click here to Skip to main content
11,647,810 members (62,811 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
Add your own
alternative version

MVC Basic Site: Step 1 – Multilingual Site Skeleton

, 25 Oct 2013 Ms-PL 185.3K 11.8K 296
This article is intended to be the first one from this series and is focused mainly in the creation of a multilingual MVC web site skeleton.
mvcbasicsitedatabase.zip
MvcBasicSiteDatabase.bak
mvcbasicsitesourcecode.zip
MvcBasicSiteSourceCode
MvcBasicSite
MvcBasic.Logic
MvcBasicSiteModel.edmx
Properties
MvcBasicSite
app_code
App_Data
App_GlobalResources
ClassDiagramUI.cd
Content
Images
dd_arrow.gif
flag_De.png
flag_En.png
flag_Ro.png
HeaderLogo.png
icon-arrow.gif
themes
base
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Controllers
Global.asax
Models
MvcBasicSite.csproj.user
Properties
Scripts
Views
Account
Home
Shared
using System;
using System.Web.Mvc;
//
using MvcBasicSite.Models;
using MvcBasic.Logic;

namespace MvcBasicSite.Controllers
{
    /// <summary>
    /// Defines the base controller.
    /// </summary>
    /// <remarks>
    /// This is the base class for all site's controllers.
    /// </remarks>
    public class BaseController : Controller
    {
        /// <summary>
        /// Gets the current site session.
        /// </summary>
        public SiteSession CurrentSiteSession
        {
            get
            {
                SiteSession shopSession = (SiteSession)this.Session["SiteSession"];
                return shopSession;
            }
        }
        /// <summary>
        /// The data context.
        /// </summary>
        protected MvcBasicSiteEntities _db = new MvcBasicSiteEntities();

        /// <summary>
        /// Dispose the used resource.
        /// </summary>
        /// <param name="disposing">The disposing flag.</param>
        protected override void Dispose(bool disposing)
        {
            _db.Dispose();
            base.Dispose(disposing);
        }

        /// <summary>
        /// Manage the internationalization before to invokes the action in the current controller context.
        /// </summary>
        protected override void ExecuteCore()
        {
            int culture = 0;
            if (this.Session == null || this.Session["CurrentUICulture"] == null)
            {
                int.TryParse(System.Configuration.ConfigurationManager.AppSettings["Culture"], out culture);
                this.Session["CurrentUICulture"] = culture;
            }
            else
            {
                culture = (int)this.Session["CurrentUICulture"];
            }
            //
            SiteSession.CurrentUICulture = culture;
            //
            // Invokes the action in the current controller context.
            //
            base.ExecuteCore();
        }

        /// <summary>
        /// Called when an unhandled exception occurs in the action.
        /// </summary>
        /// <param name="filterContext">Information about the current request and action.</param>
        protected override void OnException(ExceptionContext filterContext)
        {
            if (filterContext.Exception is UnauthorizedAccessException)
            {
                filterContext.ExceptionHandled = true;
                filterContext.Result = RedirectToAction("Home", "Index");
            }
            //
            base.OnException(filterContext);
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Raul Iloc
Program Manager SOFTVISION
Romania Romania
I am Project Manager with about 19 years working experience in software development and about 14 years as Project Manager and Architect.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150804.4 | Last Updated 25 Oct 2013
Article Copyright 2013 by Raul Iloc
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid