0

Windows認証付きASP.NET MVC 5アプリケーション。Windows認証付きのSyncfusion MVCグリッド無し

WEB.CONFIG

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

CONTROLLER

... 
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();   
    }) 
) 

アプリケーションをレンダリングできる指標Vしかし、私はデータグリッドを編集するコントローラを呼び出すが、サーバーの応答は '許可されていません'。

CONTROLLERの応答

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"> 
<!-- 

グリッドで許可を有効にする方法呼び出すか、このコントローラに許可を無効にする方法?

+0

あなたは[AllowAnonymous]が必要ないと思うWindows認証があるとき。どのコントローラーアクションが要求に入るのでしょうか? – shreesha

+0

@shreesha私はちょうど、これは、悪いURLを解決します。私は完全なパスではないアクション名だけを設定しました – BWA

+0

ああ:) @BWAなぜ[AllowAnonymous]が必要ですか? – shreesha

答えて

1

問題を解決しました。

問題は、グリッドの定義にあった:

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アクション名だけでなく、フルでなければなりません。