Kendo ui 将JsonRequestBehavior设置为AllowGet仅在组合框和下拉框上发生?
我有一个使用剑道UI的MVC4.net应用程序。当组合框和下拉列表都使用相同的函数进行读取时,我得到的是集合jsonrequestbehavior问题,而不是listview。我想填充一个下拉框。我错过什么了吗? 相关代码: cshtml的相关部分(视图): 结果协议主机URL正文缓存内容类型进程 27500 HTTP localhost:2590/Property/GetPropertyPartners?onlyActive=True 8783 private text/html;字符集=utf-8 iexplore:17452Kendo ui 将JsonRequestBehavior设置为AllowGet仅在组合框和下拉框上发生?,kendo-ui,kendo-asp.net-mvc,kendo-combobox,Kendo Ui,Kendo Asp.net Mvc,Kendo Combobox,我有一个使用剑道UI的MVC4.net应用程序。当组合框和下拉列表都使用相同的函数进行读取时,我得到的是集合jsonrequestbehavior问题,而不是listview。我想填充一个下拉框。我错过什么了吗? 相关代码: cshtml的相关部分(视图): 结果协议主机URL正文缓存内容类型进程 27500 HTTP localhost:2590/Property/GetPropertyPartners?onlyActive=True 8783 private text/html;字符集=ut
28500 HTTP localhost:2590/Property/GetPropertyPartners?onlyActive=True 8783 private text/html;字符集=utf-8 iexplore:17452
29200 HTTP localhost:2590/Property/GetPropertyPartners?onlyActive=True 132 private application/json;字符集=utf-8 iexplore:17452 编号27和28返回此json(不正确):
版本信息:Microsoft.NET Framework版本:4.0.30319;ASP.NET版本:4.0.30319.18044 29号返回此json(正确):
转载汤姆·麦克斯韦的评论作为答案 更改:
public JsonResult GetPropertyPartners([DataSourceRequest] DataSourceRequest dsRequest, bool onlyActive)
{
partners = property.GetPartnersForProperties(onlyActive);
return Json(partners, JsonRequestBehavior.AllowGet);
}
致:
我尝试在组合框和下拉列表中将serverfiltering设置为true和false。这是它的图像,因为我没有10个代表点来附加图像;返回Json(结果,JsonRequestBehavior.AllowGet);这一次它仍然有一个问题,返回正确的json,但它没有填充下拉框或组合框。我有解决方案,但它说我在8小时内无法回答我自己的问题,直到那时,解决方案将作为答案重新发布:更改的公共JsonResult GetPropertyPartners([DataSourceRequest]DataSourceRequest dsRequest,bool onlyActive){partners=property.GetPartnersForProperties(onlyActive);var result=partners.ToDataSourceResult(dsRequest);返回Json(result);}到公共JsonResult GetPropertyPartners([DataSourceRequest]DataSourceRequest dsRequest,bool onlyActive){partners=property.GetPartnersForProperties(onlyActive);返回Json(partners,JsonRequestBehavior.AllowGet);}
public JsonResult GetPropertyPartners([DataSourceRequest] DataSourceRequest dsRequest, bool onlyActive)
{
partners = property.GetPartnersForProperties(onlyActive);
var result = partners.ToDataSourceResult(dsRequest);
return Json(result);
}
<!DOCTYPE html>
<html>
<head>
<title>This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}
</style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
<br><br>
<b> Exception Details: </b>System.InvalidOperationException: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.<br><br>
<b>Source Error:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code>
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
</td>
</tr>
</table>
<br>
<b>Stack Trace:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
[InvalidOperationException: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.]
System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext context) +362369
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9628700
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
</pre></code>
</td>
</tr>
</table>
<br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044
</font>
</body>
</html>
<!--
[InvalidOperationException]: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.
at System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
{"Data":[{"PartnerID":1,"PartnerName":"test1"},{"PartnerID":2,"PartnerName":"test2"}],"Total":2,"AggregateResults":null,"Errors":null}
public JsonResult GetPropertyPartners([DataSourceRequest] DataSourceRequest dsRequest, bool onlyActive)
{
partners = property.GetPartnersForProperties(onlyActive);
var result = partners.ToDataSourceResult(dsRequest);
return Json(result);
}
public JsonResult GetPropertyPartners([DataSourceRequest] DataSourceRequest dsRequest, bool onlyActive)
{
partners = property.GetPartnersForProperties(onlyActive);
return Json(partners, JsonRequestBehavior.AllowGet);
}