Syncfusion MVC 网格未经 windows 身份验证授权

Syncfusion MVC grid unathorized with windows authentication

ASP.NET 具有 windows 身份验证的 MVC 5 应用程序。

WEB.CONFIG

...
<system.web>    
    <identity impersonate="true"/>
    <authentication mode="Windows" />
    <authorization>   
      <deny users="?" />
    </authorization>
...

控制器

...
public class TemplatesController : Controller
{
    // GET: Templates
    public ActionResult Index()
    {
        HRDataContext ctx = new HRDataContext();
        var l = ctx.SurveyTemplates.ToList();

        return View(l);
    }       

    [AllowAnonymous]
    public ActionResult Update(SurveyTemplate value)
    {
        //OrderRepository.Update(value);
        //var data = OrderRepository.GetAllRecords();
        return Json(value, JsonRequestBehavior.AllowGet);
    }

    [AllowAnonymous]
    public ActionResult Insert(SurveyTemplate value)
    {
        //OrderRepository.Add(value);
        //var data = OrderRepository.GetAllRecords();
        return Json(value, JsonRequestBehavior.AllowGet);
    }

    [AllowAnonymous]
    public ActionResult Delete(int key)
    {
        //OrderRepository.Delete(key);
        //var data = OrderRepository.GetAllRecords();
        var data = new List<SurveyTemplate>();
        return Json(data, JsonRequestBehavior.AllowGet);
    }
}
...

VIEW

@(Html.EJ().Grid<SurveyTemplate>("grdTemplate")
        .Datasource(ds => ds.Json(Model).UpdateURL("Update").InsertURL("Insert").RemoveURL("Delete").Adaptor(AdaptorType.RemoteSaveAdaptor))
    .EnableRowHover(false)
    .AllowSelection()
    .IsResponsive()
    .AllowFiltering()
    .AllowSorting()
    .FilterSettings(filter => { filter.FilterType(FilterType.Menu); })
    .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
    .ToolbarSettings(toolbar =>
    {
        toolbar.ShowToolbar().ToolbarItems(items =>
        {
            items.AddTool(ToolBarItems.Add);
            items.AddTool(ToolBarItems.Edit);
            items.AddTool(ToolBarItems.Delete);
            items.AddTool(ToolBarItems.Update);
            items.AddTool(ToolBarItems.Cancel);
        });
    })
    .Columns(col =>
    {
        col.Field("SurveyTemplateId")
            .HeaderText("Id")
            .IsPrimaryKey(true)
            .TextAlign(TextAlign.Right)
            .Width(75)
            .Visible(false)
            .Add();
        col.Field("Name").Width(100).Add();
        col.Field("Description").Width(150).Add();        
    })
)

应用程序可以呈现索引视图,但是当我编辑数据网格调用控制器时服务器响应 'not authorized'。

控制器响应

HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
X-StackifyID: V1|80000147-0003-ff00-b63f-84710c7967bb|
X-SourceFiles: =?UTF-8?B?QzpcS2Fyb2xcUHJvamVrdHlcSFIgLSBPY2VuYSBQcmFjb3duaWthXEhSIC0gT2NlbmEgcHJhY293bmlrYVxPY2VuYVByYWNvd25pa2FORVdcSW5zZXJ0?=
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Tue, 03 Jan 2017 22:55:49 GMT
Content-Length: 6128
Proxy-Support: Session-Based-Authentication

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>IIS 10.0 Detailed Error - 401.2 - Unauthorized</title> 
<style type="text/css"> 
<!-- 

如何在网格调用中启用授权或如何在该控制器中禁用授权?

问题已解决。

问题出在网格定义中:

Datasource(ds => ds.Json(Model).UpdateURL("Update").InsertURL("Insert").RemoveURL("Delete").Adaptor(AdaptorType.RemoteSaveAdaptor))

应该是:

Datasource(ds => ds.Json(Model).UpdateURL("Templates/Update").InsertURL("Templates/Insert").RemoveURL("Templates/Delete").Adaptor(AdaptorType.RemoteSaveAdaptor))

Url 不仅要填写 Action 名称,还要填写完整。