S
shapper
Hello,
I am using a custom Profile provider as follows:
public class Profile : ProfileBase {
[SettingsAllowAnonymous(false)]
public Bio Bio { get; set; }
[SettingsAllowAnonymous(true)]
public Visitor Visitor { get; set; }
public static Profile Get() {
return Create(Membership.GetUser().UserName) as Profile;
}
public static Profile Get(string username) {
return Create(username) as Profile;
}
}
Visitor is a class has follows:
[Serializable()]
public class Visitor {
public CultureInfo Culture { get; set; }
}
On my web page I am overriding InitializeCulture, by getting the value
of Visitor.Culture:
1 protected override void InitializeCulture() {
2 base.InitializeCulture();
3 CultureInfo culture = Profile.Get().Visitor.Culture;
4 if (culture != null) {
5 Thread.CurrentThread.CurrentCulture = culture;
6 Thread.CurrentThread.CurrentUICulture = culture;
7 }
8 }
Because of code line 3 I always get an error on my profile provider:
1 public static Profile Get() {
2 return Create(Membership.GetUser().UserName) as Profile;
3 }
The error is on line 2 and says:
"Object reference not set to an instance of an object. Use the new
keyword to create an object instance."
What am I doing wrong?
Thanks,
Miguel
I am using a custom Profile provider as follows:
public class Profile : ProfileBase {
[SettingsAllowAnonymous(false)]
public Bio Bio { get; set; }
[SettingsAllowAnonymous(true)]
public Visitor Visitor { get; set; }
public static Profile Get() {
return Create(Membership.GetUser().UserName) as Profile;
}
public static Profile Get(string username) {
return Create(username) as Profile;
}
}
Visitor is a class has follows:
[Serializable()]
public class Visitor {
public CultureInfo Culture { get; set; }
}
On my web page I am overriding InitializeCulture, by getting the value
of Visitor.Culture:
1 protected override void InitializeCulture() {
2 base.InitializeCulture();
3 CultureInfo culture = Profile.Get().Visitor.Culture;
4 if (culture != null) {
5 Thread.CurrentThread.CurrentCulture = culture;
6 Thread.CurrentThread.CurrentUICulture = culture;
7 }
8 }
Because of code line 3 I always get an error on my profile provider:
1 public static Profile Get() {
2 return Create(Membership.GetUser().UserName) as Profile;
3 }
The error is on line 2 and says:
"Object reference not set to an instance of an object. Use the new
keyword to create an object instance."
What am I doing wrong?
Thanks,
Miguel