c# mvc4 Ext.Net.MVC.StoreResult 不返回有效结果

标签 c# .net asp.net-mvc-4 ext.net gridpanel

我在 MVC4 + EXT.NET 库项目中创建 StoreResult Controller ,以响应 GridPanel() 中的 JsonReader()。我的 Controller 返回字符串 Ext.Net.MVC.StoreResult 而不是 json 数据。我在 VS2012、IIS8、MVC4 中创建项目。

谢谢你的帮助。

// IN VIEW

@(Html.X().GridPanel()
.ID("GridPanel1")
.Title("Array Grid")
.Width(600)
.Height(350)
.Store(s => s.Add(Html.X().Store()
    .PageSize(100)
    .Buffered(true)
    .AutoLoad(false)
    .Proxy(proxy=>proxy.Add(Html.X().AjaxProxy()
        .Url("/Data/GetData")
        .Reader(reader=>reader.Add(Html.X().JsonReader()
            .Root("data")))
     ))
    .Model(model => model.Add(Html.X().Model()
    .Fields(field =>
    {
        field.Add(Html.X().ModelField().Name("UserId"));
        field.Add(Html.X().ModelField().Name("UserName"));


    })
    ))

))
.VerticalScroller(scroller => scroller.Add(Html.X().GridPagingScroller()))
    .ColumnModel(columnModel =>
    {
        columnModel.Columns.Add(Html.X().Column()
            .Text("UserId")
            .DataIndex("UserID")
            .Flex(1)
            .Width(70));
        columnModel.Columns.Add(Html.X().Column()
            .Text("UserName")
            .DataIndex("UserName")
            .Flex(1));
        columnModel.Columns.Add(Html.X().Column()
            .Text("UserPassword")
            .DataIndex("UserPassword")
            .Flex(1));        
    })
.View(view => view.Add(Html.X().GridView().TrackOver(false)))
.Listeners(listeners =>
{
    listeners.AfterRender.Handler = "this.store.guaranteeRange(0,99);";
    listeners.AfterRender.Delay = 100;
})
)

///////// IN CONTROLLER

    public class DataController : System.Web.Mvc.Controller
    {
        //
        // GET: /Data/GetData/
        public Ext.Net.MVC.StoreResult GetData(int page = 1, int start = 0, int limit = 100)
        {

            StoreResult responce = new StoreResult();


            List<UserList> UserList = new List<UserList>();

            for (int i = start + 1; i <= start + limit; i++)
            {
                UserList user = new UserList()
                    {
                        UserId = i,
                        UserName = "UserName " + i
                    };
                UserList.Add(user);
            }

            responce.Data = UserList;
            responce.Total = 50000;
            return responce;


        }


    }

最佳答案

尝试改变这个

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.5.7" />
    <assemblyIdentity name="Ext.Net.Utilities" publicKeyToken="2c34ac34702a3c23" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0" newVersion="2.0.1" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

对此

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.5.7" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Ext.Net.Utilities" publicKeyToken="2c34ac34702a3c23" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0" newVersion="2.0.1" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

在您的 web.config 文件中。

关于c# mvc4 Ext.Net.MVC.StoreResult 不返回有效结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12817504/

相关文章:

c# - ObjectContext.GetObjectType(e.GetType()) 不返回 POCO 实体的实体类型

c# - C# 中是否有代码同义词之类的东西?

c# - 具有多个键的 EF Find()

c# - 具有虚拟方法的静态抽象对象

asp.net-mvc-4 - Google Analytics(分析)中的自定义变量

c# - 使用基于时间戳的 ReactiveX 实现移动平均

c# - 如何将异步 HttpClient 响应返回给 WinForm?

c# - 如何从 swagger.json 中删除反引号

c# - 将 [Key] 属性分配给 Entity Framework 生成的类 - MVC4 C#

asp.net-mvc-4 - 使用 SmtpClient 的 MVC 4.5 : Send an email with . pdf 附件 - 我在这里缺少什么?