kendo ui - Set JsonRequestBehavior to AllowGet only happens on combo and dropdown boxes? -


i have mvc4 .net app using kendo ui. set jsonrequestbehavior issue comboboxes , dropdowns not listview when use same function read. want populate dropdown box. missing something? relevant code:

relevant part of cshtml(view):

        <script type="text/x-kendo-tmpl" id="propertiestemplate">             <div class="partnersss">                 <h5>#:partnerid#</h5>                 <p>#:partnername#</p>             </div>         </script>         <div class="editor-field">         @(html.kendo().dropdownlist()             .name("partnerddl")             .htmlattributes(new { style = "width: 250px" })             .datatextfield("partnername")             .datavaluefield("partnerid")             .autobind(true)             .datasource(source => {             source.read(read =>             {                  read.action("getpropertypartners", "property", new { onlyactive = true });             });              })         )         @(html.kendo().combobox()             .name("partnercb")             .placeholder("select partner...")             .datatextfield("partnername")             .datavaluefield("partnerid")             .autobind(true)             .filter("contains")             .minlength(3)             .datasource(source => {             source.read(read =>             {                 read.action("getpropertypartners", "property", new { onlyactive = true });             }).serverfiltering(true);              })         )         @(html.kendo().listview<myvegas.rewards.nucleus.entities.propertypartnerview>()         .name("partnerlv")         .tagname("div")         .clienttemplateid("propertiestemplate")         .datasource(ds => ds             .read(read => read.action("getpropertypartners", "property", new { onlyactive = true }))         )         )         @html.validationmessagefor(model => model.partnerid)     </div> 

controller:

    public jsonresult getpropertypartners([datasourcerequest] datasourcerequest dsrequest, bool onlyactive)     {         partners = property.getpartnersforproperties(onlyactive);         var result = partners.todatasourceresult(dsrequest);         return json(result);     } 

result protocol host url body caching content-type process

27 500 http localhost:2590 /property/getpropertypartners?onlyactive=true 8,783 private text/html; charset=utf-8 iexplore:17452
28 500 http localhost:2590 /property/getpropertypartners?onlyactive=true 8,783 private text/html; charset=utf-8 iexplore:17452
29 200 http localhost:2590 /property/getpropertypartners?onlyactive=true 132 private application/json; charset=utf-8 iexplore:17452

number 27 , 28 give json back(incorrect):

<!doctype html> <html>     <head>         <title>this request has been blocked because sensitive information disclosed third party web sites when used in request. allow requests, set jsonrequestbehavior 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 , (max-width: 639px) {           pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }          }          @media screen , (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 disclosed third party web sites when used in request. allow requests, set jsonrequestbehavior allowget.</i> </h2></span>              <font face="arial, helvetica, geneva, sunsans-regular, sans-serif ">              <b> description: </b>an unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.              <br><br>              <b> exception details: </b>system.invalidoperationexception: request has been blocked because sensitive information disclosed third party web sites when used in request. allow requests, set jsonrequestbehavior allowget.<br><br>              <b>source error:</b> <br><br>              <table width=100% bgcolor="#ffffcc">                <tr>                   <td>                       <code>  unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using 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: request has been blocked because sensitive information disclosed third party web sites when used in request. allow requests, set jsonrequestbehavior allowget.]    system.web.mvc.jsonresult.executeresult(controllercontext context) +362369    system.web.mvc.controlleractioninvoker.invokeactionresult(controllercontext controllercontext, actionresult actionresult) +13    system.web.mvc.&lt;&gt;c__displayclass1a.&lt;invokeactionresultwithfilters&gt;b__17() +23    system.web.mvc.controlleractioninvoker.invokeactionresultfilter(iresultfilter filter, resultexecutingcontext precontext, func`1 continuation) +242    system.web.mvc.&lt;&gt;c__displayclass1c.&lt;invokeactionresultwithfilters&gt;b__19() +21    system.web.mvc.controlleractioninvoker.invokeactionresultwithfilters(controllercontext controllercontext, ilist`1 filters, actionresult actionresult) +177    system.web.mvc.async.&lt;&gt;c__displayclass2a.&lt;begininvokeaction&gt;b__20() +89    system.web.mvc.async.&lt;&gt;c__displayclass25.&lt;begininvokeaction&gt;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.&lt;&gt;c__displayclass1d.&lt;beginexecutecore&gt;b__18(iasyncresult asyncresult) +14    system.web.mvc.async.&lt;&gt;c__displayclass4.&lt;makevoiddelegate&gt;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.&lt;&gt;c__displayclass4.&lt;makevoiddelegate&gt;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.&lt;&gt;c__displayclass8.&lt;beginprocessrequest&gt;b__3(iasyncresult asyncresult) +25    system.web.mvc.async.&lt;&gt;c__displayclass4.&lt;makevoiddelegate&gt;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&amp; completedsynchronously) +155 </pre></code>                    </td>                </tr>             </table>              <br>              <hr width=100% size=1 color=silver>              <b>version information:</b>&nbsp;microsoft .net framework version:4.0.30319; asp.net version:4.0.30319.18044              </font>      </body> </html> <!--  [invalidoperationexception]: request has been blocked because sensitive information disclosed third party web sites when used in request. allow requests, set jsonrequestbehavior allowget.    @ system.web.mvc.jsonresult.executeresult(controllercontext context)    @ system.web.mvc.controlleractioninvoker.invokeactionresult(controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.<>c__displayclass1a.<invokeactionresultwithfilters>b__17()    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilter(iresultfilter filter, resultexecutingcontext precontext, func`1 continuation)    @ system.web.mvc.controlleractioninvoker.<>c__displayclass1a.<>c__displayclass1c.<invokeactionresultwithfilters>b__19()    @ system.web.mvc.controlleractioninvoker.invokeactionresultwithfilters(controllercontext controllercontext, ilist`1 filters, actionresult actionresult)    @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass25.<>c__displayclass2a.<begininvokeaction>b__20()    @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass25.<begininvokeaction>b__22(iasyncresult asyncresult)    @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.end()    @ system.web.mvc.async.asynccontrolleractioninvoker.endinvokeaction(iasyncresult asyncresult)    @ system.web.mvc.controller.<>c__displayclass1d.<beginexecutecore>b__18(iasyncresult asyncresult)    @ system.web.mvc.async.asyncresultwrapper.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar)    @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.end()    @ system.web.mvc.controller.endexecutecore(iasyncresult asyncresult)    @ system.web.mvc.async.asyncresultwrapper.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar)    @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.end()    @ system.web.mvc.controller.endexecute(iasyncresult asyncresult)    @ system.web.mvc.controller.system.web.mvc.async.iasynccontroller.endexecute(iasyncresult asyncresult)    @ system.web.mvc.mvchandler.<>c__displayclass8.<beginprocessrequest>b__3(iasyncresult asyncresult)    @ system.web.mvc.async.asyncresultwrapper.<>c__displayclass4.<makevoiddelegate>b__3(iasyncresult ar)    @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.end()    @ system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult)    @ system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result)    @ system.web.httpapplication.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute()    @ system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) --> 

number 29 gives json back(correct):

{"data":[{"partnerid":1,"partnername":"test1"},{"partnerid":2,"partnername":"test2"}],"total":2,"aggregateresults":null,"errors":null} 

reposting tom maxwell's comment answer.

changed:

public jsonresult getpropertypartners([datasourcerequest] datasourcerequest dsrequest, bool onlyactive)  {       partners = property.getpartnersforproperties(onlyactive);       var result = partners.todatasourceresult(dsrequest);       return json(result);  }  

to:

public jsonresult getpropertypartners([datasourcerequest] datasourcerequest dsrequest, bool onlyactive)  {            partners = property.getpartnersforproperties(onlyactive);            return json(partners, jsonrequestbehavior.allowget);  }  

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -