Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3330844
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:31:41+00:00 2026-05-17T23:31:41+00:00

I am using the spark viewengine, asp.net mvc, and .resx files. I want to

  • 0

I am using the spark viewengine, asp.net mvc, and .resx files.

I want to set a language through my custom SessionModel (Session) which is registered through Castle.Windsor and has a string property of Culture which can be set by the user…

I need the current language to persist on every view, without having to constantly set the current UICulture.

Not having to do this everytime in each Controller Action:

    public SessionModel SessionModel { get; set; }

    public ActionResult Index()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SessionModel.Culture);
        Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
    }

The problem with doing it this way, is if I go onto another page the current culture will flip back to the default language.

On the spark view I simply call, to obtain the current Culture:

${SR.Home}

SR.resx contains a public entry for Home.

Does anyone have a good idea of how to do this, should I do this with an ActionFilter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:31:42+00:00Added an answer on May 17, 2026 at 11:31 pm

    Action filter seems like a good idea:

    public class SetCultureActionFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CultureInfo culture = FetchCultureFromContext(filterContext);
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
            base.OnActionExecuting(filterContext);
        }
    
        private CultureInfo FetchCultureFromContext(ActionExecutingContext filterContext)
        {
            throw new NotImplementedException();
        }
    }
    

    and then decorate your base controller with this attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What pros(positive sides) of using Spark view engine for ASP.NET MVC project. Why it
I'm using the spark view engine with my asp.net mvc application. In my aspx
I'm using ASP.NET MVC (1.0), Spark View Engine (1.0) and SubSonic (3.0.0.3). I'm having
Using ASP.NET MVC there are situations (such as form submission) that may require a
I decided to use ASP.NET MVC, S#arp Architectur and the Spark View Engine for
I am using the SparkViewEngine with ASP.NET MVC 1.0 and was wondering if there
After pushing my asp.net mvc (with spark view engine) project to our live server
I'm using the Spark view engine, and want to localize the website. The methods
I am playing with ASP.NET MVC and I see that there are a few
I am working with an ASP.NET MVC project which was originally started from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.