O.O
O.O

Reputation: 11287

ASP.NET MVC 4 Cannot access Resource files

I have a resource file Res.en-US.resx with:

When I try to include them in a .cs page or a razor view, it does not show up at all. I can't add using or use long namespace to the resource, it simply isn't there.

I want to be able to do:

<label>@Resources.Blah.LocationString</label>

Ideas?

Upvotes: 0

Views: 2698

Answers (4)

Mohammad Naushad M
Mohammad Naushad M

Reputation: 56

this issue comes because of missing of designer res file ,adding of Custom tool will resolve the issue.

  • go to properties of resource
  • update Custom tool value as 'PublicResXFileCodeGenerator'

Upvotes: 0

Karl &#214;hman
Karl &#214;hman

Reputation: 1

A late response, but I found this thread when I had a similar issue.

I had my Resources.resx file in a separate project from the main MVC application. I had added the resource project as a project reference, but the resource strings would not appear.

The problem was that the Access modifier of the .resx file was set to Internal by default. When I changed the setting to public I was able to refer to the resource strings like @Resources.Blah.LocationString as expected.

Upvotes: 0

user1657421
user1657421

Reputation: 31

You need to have one file without dot and another one same name but with dot and something, for example:

Shared.resx and Shared.en-GB.resx

Upvotes: 3

O.O
O.O

Reputation: 11287

Turns out it wasn't working because of the way I named the resource file. It works once I remove all the "."'s

Upvotes: 0

Related Questions