ASP.NET Core 2.1-更新后,无法再删除TempData中的数据

时间:2018-10-01 12:13:46

标签: c# asp.net .net asp.net-core asp.net-core-2.1

我在我的ASP.NET Core应用程序中使用Vereyons FlashMessage(https://github.com/Vereyon/FlashMessage),并且从.NET Core 2.0更新到2.1之后,从TempData删除消息不再起作用。

我发现,当我阅读(在视图中调用RenderFlashMessages方法)Flash消息时,应该删除Flash消息。但这不会发生,TempData中的Flash消息将保留。

当我查看Vereyon的代码时,我发现它应该像这样工作:

1)在视图中调用RenderFlashMessages。 2)RenderFlashMessages调用FlashMessage.Retrieve方法 3)Retrieve方法应从TempData中删除Flash消息

从Vereyon的代码中检索方法片段:

    public static List<FlashMessageModel> Retrieve(ITempDataDictionary dictionary)
    {

        // Retrieve the data from the session store, guard for cases where it does not exist.
        var data = dictionary[KeyName];
        if (data == null)
            return new List<FlashMessageModel>();

        // Clear the data and return.
        dictionary.Remove(KeyName);
        return Deserialize((byte[])data);
    }

有一些解决方法吗?我不想编辑Vereyons代码,因为有nuget和更新等。

编辑:在我的应用中,TempData存储在cookie中

0 个答案:

没有答案