Global Resources not working in Production Environment

Just deployed my solution to a production environment to notice that the Global Resources where not working properly. The first thing which comes to mind is are the actually on the production server and it appears they where not.

The reason was because the resource file was marked as embedded resource instead of content.


Mark your global resources as content

Be sure to mark your resource file as content so that it get's compiled. You can notice the difference when you're investigating the result of the build. Notice that in the first build it's actually an embedded resource and in the second a compiled dll.


Another fine solution

Hope this makes your day.


Avoid imports on ASPX pages

Sometimes you want to refer to constants or use an extension method in your aspx code. To get to these methods you can add imports to your pages like:

<%@ Import Namespace="PropertyWell.WebUI.Code.UIConstants" %>
<%@ Import Namespace="PropertyWell.Common.Extensions" %>

If you don't want to add these to your pages because you use them regularly you can add them to your web.config.

        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="PropertyWell.WebUI.Code.UIConstants" />
        <add namespace="PropertyWell.Common.Extensions" />

Using local resources at design time

There are different types of resources and one of them is local resources. When you want to use your local resources at design time you have multiple options in using them one of them is. The control on which we are using the local resource is OpenAuthProviders.ascx


Alternate Text and Title

As you'll notice the local resource is used as alternate text and as a title. The local resources are defined as strings in the associating local resource file(s).  

Success in localizing your site(s)

Hope you'll be able to use this in the future. 

This code is used on


Using local resources on a WebForm

If you want to use local resource text on a webforms page you can wrap it in a literal control or create a public or protected method on your code behind or base page. By creating a method like:


        public string GetLocalResource (string key)
            object resourceString = GetLocalResourceObject(key);

            return (resourceString != null) ? resourceString.ToString() : "Resource not available";

You can use local resources on your webform like:

<h1><%= GetLocalResource("resourcekey") %></h1>

or when your in a databound control:


<%# GetLocalResource("resourcekey") %>


Hope this is of any use o you in the future.

Sponsored by


<<  February 2019  >>

View posts in large calendar