ASP.NET MVC: dealing with Version field.
        Posted  
        
            by alex2k8
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by alex2k8
        
        
        
        Published on 2009-06-14T11:39:58Z
        Indexed on 
            2010/04/19
            11:43 UTC
        
        
        Read the original article
        Hit count: 345
        
I have a versioned model:
public class VersionedModel
{
    public Binary Version { get; set; }
}
Rendered using
<%= Html.Hidden("Version") %>
it gives:
<input id="Version" name="Version" type="hidden" value=""AQID"" />
that looks a bit strange. Any way, when the form submitted, the Version field is always null.
public ActionResult VersionedUpdate(VersionedModel data)
{ 
    ...
}
How can I pass Version over the wire?
EDIT:
A naive solution is:
public ActionResult VersionedUpdate(VersionedModel data)
{ 
    data.Version = GetBinaryValue("Version");
}
private Binary GetBinaryValue(string name)
{
    return new Binary(Convert.FromBase64String(this.Request[name].Replace("\"", "")));
}
© Stack Overflow or respective owner