Application ASP.NET MVC 5 avec authentification Windows.Grille Syncfusion MVC non authentifiée avec l'authentification Windows
web.config
...
<system.web>
<identity impersonate="true"/>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
...
CONTRÔLEUR
...
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();
})
)
application peut rendre Index v iew, mais quand je modifie le contrôleur de la grille des appels de données, mais la réponse du serveur n'est pas autorisée.
Réponse du contrôleur
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">
<!--
Comment activer l'autorisation dans la grille des appels ou comment désactiver l'autorisation dans ce contrôleur?
Lorsque vous avez une authentification Windows, je ne pense pas que vous ayez besoin de [AllowAnonymous]. quelle action de contrôleur la demande va-t-elle? – shreesha
@shreesha Je viens de résoudre ce problème, mauvaise url. Je ne mets que le nom de l'action pas le chemin complet – BWA
oh génial :) @BWA pourquoi avons-nous besoin de [AllowAnonymous] ici? – shreesha