更改实体时出现不规则的无效cryptoTicket

时间:2018-11-13 13:27:19

标签: asp.net asp.net-mvc entity-framework-6 umbraco umbraco7

我一直在研究Asp.net/umbraco 7.12项目。 但是,当我以成员身份登录时,我尝试操纵模型实体中Icollection中的第一个实体,但它始终为我提供无效EncryptedTicket值的异常。即使它在所有其他实体上都可以正常工作。我曾尝试清除Cookie,并检查特定实体是否存在问题,但似乎都不是问题。 我的假设是某事禁止我使这两个实体之间的关系完全为零,但是不幸的是,我没有经验告诉我。 如果有人得到任何线索,那将非常有帮助。

型号:

[Table("Vestigingen")]
public class Vestiging :I_modified
{
    [Display(Name = "Vestiging naam" )]
    public string Naam { get; set; }

    [Display(Name = "Adres")]
    public string Adres { get; set; }

    [Display(Name = "Vestiging ID")]
    public int ID { get; set; }

    [Display(Name = "Datum aangemaakt")]
    public DateTime Created { get; set; }

    [Display(Name = "Datum aangepast")]
    public DateTime Modified { get; set; }

    [Display(Name = "Aangemaakt door")]
    public string CreatedBy { get; set; }

    [Display(Name = "Aangepast door")]
    public string ModiFiedBy { get; set; }

    [Display(Name = "Status")]
    public Status Status { get; set; }

    public virtual ICollection<MemberMedewerker> Medewerkers { get; set; }
    public virtual ICollection<MemberLeerling> Leerlingen { get; set; }
}

查看:

 <br />
<div class="form-row">
    <div class="col-sm-3">
        <h4>Medewerkers gekoppeld aan vestiging</h4>
        <table class="table  table-sm dataTable no-footer" role="grid">
            <tbody>
                @foreach (var medewerker in Model.Medewerkers)
                {
                    if (medewerker.Status == Status.Active)
                    {
                        <tr id="">
                            <td class="clickable-row" role="row" data-url="/HR/medewerkeraanpassen/?memberId=@medewerker.ID">@medewerker.Naam</td>
                            @using (Html.BeginUmbracoForm<HRController>("MedewerkerOntKopellenVanVestiging", null))
                            {
                                <td>
                                    <input name="vestigingId" class="form-control" id="" type="text" value="@Model.ID" hidden />
                                    <input name="memberId" class="form-control" id="" type="text" value="@medewerker.ID" hidden />
                                    <button class="btn btn-primary" type="submit">Ontkoppelen</button>
                                </td>
                            }
                        </tr>

                    }
                }
            </tbody>
        </table>
    </div>

ControllerHelper:

public void MedewerkerOntKopellenVanVestiging(int vestigingId, int memberId)
    {

        using (dalcontext)
        {
            var medewerker = dalcontext.MemberMedewerkers.FirstOrDefault(x => x.ID == memberId);
            var vestiging = dalcontext.Vestigingen.FirstOrDefault(x => x.ID == vestigingId);

            vestiging.Medewerkers.Remove(medewerker);

            dalcontext.SaveChanges();
        }


    }

"Ontkoppelen" will usually hit the controller to remove the entity out of the ICollection except if I click on "Ontkoppelen" on the very first entity

Exception Details

Example of it going right by removing the 2nd entity from the ICollection

1 个答案:

答案 0 :(得分:0)

我在使用Fiddler的帮助下解决了该问题,当列表在视图中为空时,将发布错误的数据。所以我通过分离表格来解决它。希望它对其他获得此异常的人有所帮助。