How to create resource manager in ASP.NET

Posted by Bart on Stack Overflow See other posts from Stack Overflow or by Bart
Published on 2010-04-04T08:16:18Z Indexed on 2010/04/04 8:23 UTC
Read the original article Hit count: 420

Filed under:
|
|

Hello, I would like to create resource manager on my page and use some data stored in my resource files. (default.aspx.resx and default.aspx.en.resx)

The code looks like this:

System.Resources.ResourceManager myResourceManager = System.Resources.ResourceManager.CreateFileBasedResourceManager("resource", 
               Server.MapPath("App_LocalResources") + Path.DirectorySeparatorChar, null);

    if (User.Identity.IsAuthenticated)
    {
        Welcome.Text =  myResourceManager.GetString("LoggedInWelcomeText");
    }
    else
    {
        Welcome.Text = myResourceManager.GetString("LoggedOutWelcomeText");
    }

but when i compile and run it on my local server i get this type of error:

Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: resource locationInfo: fileName: resource.resources Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: resource locationInfo: fileName: resource.resources

Source Error:

Line 89: else Line 90: { Line 91: Welcome.Text = myResourceManager.GetString("LoggedOutWelcomeText"); Line 92: } Line 93:

can you please assist me with this issue?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#