猿问

POST Guid to WebAPI 接收为 NULL

所以我决定在这里写下我自己的答案,因为我不确定其他人是否会解决这个问题。我怀疑的一件事是我最近将 C# 语言更新到了 v7.3,因为 VS 2017 在编写一些代码时是这样说的。也许问题与此有关,但到目前为止我的解决方案在最小化状态下工作。


我还想在此声明,我BackgroundTask首先实施以ApplicationTrigger在需要时触发该过程来克服这个问题,但老实说这是一种黑客攻击。看一下代码:


public static async Task<string> GetBackgroundTaskReturnValue(string apiRequestUrl)

{

        StaticItemsHelper.IsBackgroundPlaylistTaskRunning = true;

        if (StaticItemsHelper.IsBackgroundPlaylistTaskRunning)

        {

            for (int seconds = 0; seconds < 20;)

            {

                if (!StaticItemsHelper.IsBackgroundPlaylistTaskRunning)

                {

                    break;

                }

                else

                {

                    Task.Delay(1000).Wait();

                }

            }

        }

        var request = BackgroundTaskHelper.BackgroundPlaylistTrigger.RequestAsync().GetResults();

        if (request == Windows.ApplicationModel.Background.ApplicationTriggerResult.Allowed)

        {

            SettingsHelper.localSettings.Values[SettingsHelper.BackgroundPlaylistPlaybackURLKey] = apiRequestUrl;

            SettingsHelper.localSettings.Values[SettingsHelper.BackgroundPlaylistPlaybackTokenKey] = StaticItemsHelper.CurrentUserAccessToken;

            if (SettingsHelper.tempFolder.TryGetItemAsync(SettingsHelper.BackgroundPlaylistPlaybackReturnKey).GetResults() is StorageFile file)

            {

                await file.DeleteAsync();

            }

            for (int seconds = 0; seconds < 30;)

            {

                if (SettingsHelper.tempFolder.TryGetItemAsync(SettingsHelper.BackgroundPlaylistPlaybackReturnKey).GetResults() is StorageFile _rfile)

                {



牛魔王的故事
浏览 235回答 1
1回答

守着一只汪

您确定 String 名称在 json 中传递了值吗?如果你想用 JsonSerializer 反序列化,我认为像你 TransferObject 这样的公共 api 不应该有内部属性(和内部 setter 或 getter)。JsonSerializer 是外部 .dll 并且无法访问您的 setter。让我们尝试使用公共二传手。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答