用点处理 属性 的函数
Function to handle property with dot
如何处理此 post 请求,我有一个页面 post 的数据类似于
https://localhost:80/Test/ValidateZeroBounce?ClientInfo.Email=test@test.comm
我在控制器中创建了一个函数来处理 class 对象中的数据,但它始终为 null
public ActionResult ValidateZeroBounce(ClientInfo Model)
{
}
public class ClientInfo
{
public string Email { get; set; }
public string EmailJoint { get; set; }
}
我如何处理该值?
将此添加到启动项
services.Configure<ApiBehaviorOptions>(options =>
{
options.SuppressInferBindingSourcesForParameters = true;
});
那么你可以使用这个语法
https://localhost/Test/ValidateZeroBounce?Email=test@test.comm
或者你可以试试这个,但在这种情况下它没有多大意义
https://localhost/Test/ValidateZeroBounce?model.Email=test@test.comm
或者如果你使用的是旧版本的网络,这样做会更容易
public ActionResult ValidateZeroBounce(string email, string emailJoint)
{
var model= new ClientInfo {Email=email, EmailJoint=emailJoint};
....
}
如何处理此 post 请求,我有一个页面 post 的数据类似于
https://localhost:80/Test/ValidateZeroBounce?ClientInfo.Email=test@test.comm
我在控制器中创建了一个函数来处理 class 对象中的数据,但它始终为 null
public ActionResult ValidateZeroBounce(ClientInfo Model)
{
}
public class ClientInfo
{
public string Email { get; set; }
public string EmailJoint { get; set; }
}
我如何处理该值?
将此添加到启动项
services.Configure<ApiBehaviorOptions>(options =>
{
options.SuppressInferBindingSourcesForParameters = true;
});
那么你可以使用这个语法
https://localhost/Test/ValidateZeroBounce?Email=test@test.comm
或者你可以试试这个,但在这种情况下它没有多大意义
https://localhost/Test/ValidateZeroBounce?model.Email=test@test.comm
或者如果你使用的是旧版本的网络,这样做会更容易
public ActionResult ValidateZeroBounce(string email, string emailJoint)
{
var model= new ClientInfo {Email=email, EmailJoint=emailJoint};
....
}