views:

105

answers:

1

I'm using the SqlMembershipProvider to carry out my ASP.NET website's user management. In particular, the site needs to be multi-lingual (globalized!).

When I create users using Membership.CreateUser it's good that I get exceptions for things like duplicate emails, duplicate usernames etc. But what I want is to re-use that exception text by having it localized into the current thread culture.

I'm positive I'm setting the current thread UI culture correctly, etc since all other globalization features are fully functional.

I was under the impression all .NET Framework exception texts were globalized. Aren't they???

In particular, I'm testing for french. I think I've successfully installed the French .NET 3.5 SP1 Language Pack (but not certain - is there a way to check!?) following instructions from here.

Is it maybe the case that just the System.Web.Security.Membership exceptions aren't localized? Or am I missing an environment configuration step?

Any help would be great.

Andrew.

+1  A: 

The exception messages are not localized.

You must localize them your self using the error codes:

Public Shared Function ErrorCodeToString( _
                    ByVal createStatus As MembershipCreateStatus) As String
    Select Case createStatus
        Case MembershipCreateStatus.DuplicateUserName
            Return Resources.Resource.Account_DuplicateUserName

        Case MembershipCreateStatus.DuplicateEmail
            Return Resources.Resource.Account_DuplicateEmail

        ...

See this MSDN link for a full list of status codes.

Eduardo Molteni