我已经使用Telerik Kendo UI和Asp.Net Core 2.0控件创建了一个应用程序。在本地,我们能够在Visual Studio 2017中运行相同的代码而不会出现错误,但是在本地IIS中发布后,它会给出以下错误(请参见下图)。
错误:-“http://localhost:91/Masters/GetStateList404(未找到)”。
[检查错误时发现只有网格的Read方法(可能是由于'[DataSourceRequest] DataSourceRequest'参数所致)不被调用(其他就像下面的代码“ GetRecordStatusList()']
一样完美地调用了action方法控制器:
public class MastersController : Controller
{
private IAllRepository<StateMaster> iAllStateRepository;
public IActionResult StateMaster()
{
List<SelectListItem> statusList = new List<SelectListItem>() {
new SelectListItem{Text = "Active", Value = "1" },
new SelectListItem{Text = "Inactive", Value = "2" }
};
HttpContext.Session.SetInt32("UserId", 1);
HttpContext.Session.SetString("UserName", "Admin");
ViewBag.UserName = HttpContext.Session.GetString("UserName");
return View();
}
//This action method is not called in published-code
public ActionResult GetStateList([DataSourceRequest]DataSourceRequest request)
{
this.iAllStateRepository = new StateMasterRepository();
var result = iAllStateRepository.GetModelList();
var dsResult = result.ToDataSourceResult(request);
return Json(dsResult);
}
public JsonResult GetRecordStatusList()
{
List<SelectListItem> statusList = new List<SelectListItem>() {
new SelectListItem{Text = "Active", Value = "1" },
new SelectListItem{Text = "Inactive", Value = "2" }
};
return Json(statusList);
}
}
更新:这是视图(StateMaster.cshtml)代码
<div class="row">
@(Html.Kendo().Grid<Entity.MasterEntity.StateMaster>()
.Name("StateGrid")
.Columns(columns =>
{
columns.Bound(p => p.StateName).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(true).Operator("contains"))).Width(120);
columns.Bound(p => p.Abbr).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(true).Operator("contains"))).Width(120).MinScreenWidth(800);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(70);
})
.ToolBar(toolbar =>
{
toolbar.ClientTemplateId("toolbarStatus");
})
.NoRecords(e => e.Template("<div class='alert alert-warning' style='padding:3px'><h6 class='bold'><i>No data found!</i></h6></div>"))
.Pageable(p => { p.Refresh(true); p.PageSizes(true); }).Navigatable()
.Sortable(s => s.SortMode(GridSortMode.MultipleColumn)).Scrollable(s => s.Enabled(true))
.HtmlAttributes(new { style = "height:100%;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.ServerOperation(true)
.Model(m =>
{
m.Id(s => s.StateId);
m.Field(f => f.StateName);
m.Field(f => f.Abbr);
m.Field(f => f.RecordStatus);
})
.Read(read => read.Action("GetStateList", "Masters"))
)
.Resizable(resize => resize.Columns(false))
)
</div>
下图显示的是开发中的图像,它表明网格的读取方法正常工作。
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9sakhaUy5wbmcifQ==” alt =“在开发环境中工作图像”>“ >>
我已经使用Telerik Kendo UI和Asp.Net Core 2.0控件创建了一个应用程序。在本地,我们能够在Visual Studio 2017中运行相同的代码而不会出错,但是在本地IIS中发布后,它可以...
我遇到一种情况,如果将区域映射到站点中其他任何地方的路由中,则有时找不到控制器动作。为了解决这个问题,您可以通过执行以下操作清除区域: