Здравствуйте....
Следуя
Accessing the ASP.NET Authentication, Profile and Role Service in Silverlight примеру
Создал сервис:
1.
<%@ ServiceHost Language="C#" Service="System.Web.ApplicationServices.ProfileService" %>
Web.Config настроил так:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
<?xml version="1.0"?>
<configuration>
<system.web>
<roleManager enabled="true" />
<authentication mode="Forms" />
<profile>
<properties>
<add name="Color" type="string" defaultValue="Red"/>
<add name="Order" type="ApplicationServicesDemo.Web.Order"/>
</properties>
</profile>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<authenticationService enabled="true" requireSSL="false"/>
<profileService enabled="true" readAccessProperties="Color, Order" writeAccessProperties="Color, Order"/>
<roleService enabled="true"/>
</webServices>
</scripting>
</system.web.extensions>
<system.serviceModel>
<services>
<!-- this enables the WCF RoleService endpoint -->
<service name="System.Web.ApplicationServices.RoleService"
behaviorConfiguration="RoleServiceTypeBehaviors">
<endpoint contract="System.Web.ApplicationServices.RoleService"
binding="basicHttpBinding" bindingConfiguration="userHttp"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
<!-- this enables the WCF ProfileService endpoint -->
<service name="System.Web.ApplicationServices.ProfileService"
behaviorConfiguration="ProfileServiceTypeBehaviors">
<endpoint contract="System.Web.ApplicationServices.ProfileService"
binding="basicHttpBinding" bindingConfiguration="userHttp"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
<!-- this enables the WCF AuthenticationService endpoint -->
<service name="System.Web.ApplicationServices.AuthenticationService"
behaviorConfiguration="AuthenticationServiceTypeBehaviors">
<endpoint contract="System.Web.ApplicationServices.AuthenticationService"
binding="basicHttpBinding"
bindingConfiguration="userHttp"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="userHttp">
<!-- this is for demo only. Https/Transport security is recommended -->
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="AuthenticationServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior name="ProfileServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior name="RoleServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!-- this is needed since this service is only supported with HTTP protocol -->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
</configuration>
мой класс Order выглядит так:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
[DataContract]
public class Order
{
[DataMember]
public string Product { get; set; }
[DataMember]
public int Qty { get; set; }
public Order()
{
this.Product = string.Empty;
this.Qty = 0 ;
}
}
ошибка десериализации происходит при попытке получить свойства профайла из silverlight client
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
ProfileServiceClient pc = new ProfileServiceClient();
pc.GetAllPropertiesForCurrentUserCompleted += (object sender, GetAllPropertiesForCurrentUserCompletedEventArgs e) =>
{
if (e.Error == null)
{
ChangeBackColor(e.Result["Color"].ToString());
Order o = e.Result["Order"] as Order;
}
};
pc.GetAllPropertiesForCurrentUserAsync(false);
Причем если оставить только свойство Color, все работает наура........
т.е. у меня не получается в свойствах Profile сохранить CustomType (Order)
Пробовал без аттрибутов DataContract/DataMember.
пробовал с аттрибутом Serializable
не канает.
Извечный вопрос: Как быть?
p.s. сорри за "длинный" вопрос ...........