我正在尝试从控制器操作结果中填充下拉列表,但是在尝试从“身份注册”页面调用操作时收到错误500。 这是在本地主机上,我的断点没有命中。
前端(Register.cshtml)
@(Html.Kendo().ComboBox()
.Name("products")
.Placeholder("Select product")
.DataTextField("Name")
.DataValueField("CountryId")
.HtmlAttributes(new { style = "width:100%;" })
.Filter(FilterType.Contains)
.AutoBind(false)
.MinLength(3)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetProducts", "UserDetails");
})
.ServerFiltering(true);
})
)
控制器:
[Route("userdetails")]
public partial class UserDetailsController : Controller
{
public UserDetailsService _userDetailsService;
public UserDetailsController(UserDetailsService userDetailsService)
{
_userDetailsService = userDetailsService;
}
public ActionResult GetProducts()
{
// run synchronously as partials cannot use async
List<ViewModels.CountriesSelectList> task = _userDetailsService.GetCountriesSelectList();
var results = task;
return Json(results);
}
我尝试将其从“获取”更改为“帖子”,但错误从500更改为405,我认为身份阻止了通话
我希望得到所有国家的清单