Failed to deserialize viewModel encrypted values
Hi, when trying to set object property with childs (and at least one child property is set to SignData) with static command then the viewModel cant be deserialize after postback:
- for testing, at first click on "static" button, then on "postback" button
Html:
<dot:Button Text="static" Click="{staticCommand: Selected = xxx.ViewModels.TestViewModel.Set() }"></dot:Button>
<dot:Button Text="postback" Click="{command: Postback()}"></dot:Button>
C#:
public A Selected { get; set; } = new A();
[AllowStaticCommand]
public static A Set()
{
return new A()
{
Id = "2",
Name = "Name of A",
Bs = new List<B>()
{
new B(){
Id = "22",
Name = "Name of B"
}
}
};
}
public void Postback()
{
}
public class A
{
[Protect(ProtectMode.SignData)]
public string Id { get; set; }
public string Name { get; set; }
public List<B> Bs { get; set; } = new List<B>();
}
public class B
{
[Protect(ProtectMode.SignData)]
public string Id { get; set; }
public string Name { get; set; }
}
I'm sorry, but encrypted/signed values don't work with static commands, and I don't see a reasonable way to make it work.
We should however produce a more reasonable error, probably disallow the assignment if the object contains anything marked with the Protect attribute
Ok, understand. It's necessary produce error? I would expect that signed properties will not be just assigned. My situation:
- I have grid where items have signed Id property.
- I want to create infobox of focused row item somewhere in page
- so I would like to on rowclick just assign item to some property in viewmodel to show selected data in infobox
- and i dont want to make classic postback, because i have all data already on client and want them just show in different place in page
But then the deserialization is not possible, since the signed part of an object is missing.
You could work around this by having a property with selected row index, instead of the selected row. Or by adding Bind(ServerToClientFirstRequest) on the SelectedRow property.