小编hig*_*boi的帖子

为什么我的隐藏输入没有在模型类中传递?

我有一个带有嵌套类的 Dto 类,我用它来将模型绑定到我的视图。嵌套类有一个id属性需要传递回我的应用程序服务,但到目前为止我得到null

我尝试过的一些事情是

<input asp-for="StoreWalk.Department.Id" type="hidden" />
@Html.HiddenFor(h => h.StoreWalk.Department.Id)
<input type="hidden" name="version" value="@Model.StoreWalk.Version" />
<input type="hidden" name="department.id" value="@Model.StoreWalk.Department.Id" />
<input type="hidden" name="department_id" value="@Model.StoreWalk.Department.Id" />
<input type="hidden" id="StoreWalk_Department_Id" name="department_id" value="@Model.StoreWalk.Department.Id" />
Run Code Online (Sandbox Code Playgroud)

我的模特班

public class CreateOrEditStoreWalkViewModel
{
    public CreateOrEditStoreWalkDto StoreWalk { get; set; }
    public bool IsEditMode => StoreWalk.Id.HasValue;
}


public class CreateOrEditStoreWalkDto : EntityDto<int?>
{
    // Id property is implemented in `EntityDto` as int?

    [Required]
    public string Store { get; set; }

    public string Comments { …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc asp.net-core

4
推荐指数
1
解决办法
4446
查看次数

如何使用可编码打印 alamofire 响应的结果

对于 codable 新手,我尝试使用 codable 为 alamofire 创建一个类,并尝试发出 api 请求。我收到一些 Swift.DecodingError.typeMismatch 错误,并且由于我的模型类而发现了它。现在我需要的是在解码之前以 JSON(String) 格式打印 alamofire 响应,以便我可以识别 typeMismatch

static func performRequest<T:Decodable>(route:APIRouter, decoder: JSONDecoder = JSONDecoder(), completion:@escaping (Result<T,Error>)->Void) -> DataRequest {

    return AF.request(route)
        .responseDecodable (decoder: decoder){ (response: DataResponse<T>) in
            print(response.result)
            completion(response.result)
    }
}
Run Code Online (Sandbox Code Playgroud)

我想要一些代码来打印 alamofire 的实际结果

ios alamofire codable swift5

1
推荐指数
1
解决办法
1884
查看次数

标签 统计

alamofire ×1

asp.net-core ×1

asp.net-core-mvc ×1

c# ×1

codable ×1

ios ×1

swift5 ×1