Joel Peltonen
Joel Peltonen

Reputation: 13412

Asp.net mvc3 localization - linking resource with view?

I use the localization paradigm of one resx file per view in all my projects. I have two identical folder structures for Resources and Views and I link the resource and the view like so:

@using Res = [Namespace].Resources.[Controller].[View]
<p>@Res.[ResourceKey]</p>

Is it possible to get asp.net to use/link the resource file without the using statements and defining a Custom Tool Namespace for all my Resx files? (Yes, I am that lazy.)

Upvotes: 2

Views: 661

Answers (1)

Matija Grcic
Matija Grcic

Reputation: 13381

Open your web.config in your Views folder.

enter image description here

Add the namespace for your resources.

enter image description here

Restart VS as it doesn't pick up the namespace so it's not showing intellisense.

Call your resources from any view without adding using statements inside your *.cshtml files.

Upvotes: 1

Related Questions