问题标签 [jsonresult]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - 排序不适用于提供编码输出的 Json 结果
我正在使用 Json Result 来显示一个表格,当我显示结果时它工作正常。现在我想给它添加一个排序功能,所以我使用了 canSort:true 属性。但是现在,当我单击表格的标题进行排序时,我会在浏览器中得到下面的编码字符串,它似乎也已排序,但对其进行了某种编码,如下所示。
我知道下面的代码中可能存在一些不一致之处,因为我必须删除版权问题的实际列。
Javascript代码
c# - Return file in JsonResult or return Json data in ActionResult?
Using an MVC3 .net controller on the back-end, I am performing an HttpPost to submit a file via the HttpContext.
When the server reads the file, a list of strings is returned with the upload results.
So far, I have been able to get two scenarios working:
1) Return the list of strings as a single, tab-delimited string as a JsonResult
2) Return the list of strings in a text file as an ActionResult
My problem is that I want elements from each of these methods but am having difficulty combining the two. I want the JsonResult so that I can return a boolean 'success' value to release a modal, waiting message on the client. I want the ActionResult so that the client can simply download a file instead of parsing the list of strings into the GUI components.
Is there a way to return a text file to be downloaded as part of the JsonResult or return Json data with the ActionResult?
Thank you for reading
html - 用 HTML 包含对象属性并以 JSON 格式返回
目前,我已经编写了以下 json 搜索方法。
在屏幕上,它返回这个。
我应该怎么办?我想这样做的原因是,我可以利用 CSS 来设置标签样式,以便在项目从搜索输入中下拉时看起来更美观。
谢谢
c# - 从 MVC 3 JsonResult 获取美化 JSON
上下文
语言:C#
平台版本:Microsoft .Net Framework 4.0
操作系统:Windows 7 Professional(64 位)
约束:Microsoft MVC.Net 3.0
问题
这些天我发现自己在浏览器中经常查看 JSON,将浏览器指向本地开发服务器上的一个或另一个控制器操作,并以可视方式解析 JSON 以确保所有内容都按照我们想要的方式进行格式化。MVC 3 序列化程序(或 JSON.Net 序列化程序)返回的 JSON 总是返回一个缩小的字符串,所以我最终得到这样的结果:
问题
我真的很想找到一种方法,至少在调试期间,让 JsonResult 被“美化”,使其看起来更像这样:
我知道有几个 在线 工具可以让您粘贴和格式化 JSON。这是一个额外的步骤,并且花费了我很多时间。我更喜欢程序化解决方案。我还希望能够通过配置或#if 编译器指令打开/关闭它。
我已经对此进行了粗略的搜索,并在 Stack Overflow 上看到了这篇文章。但是,给出的代码示例非常不完整。还提供了几个链接,但它们似乎已失效。
无论如何,我想找到一种从 ActionResult 中获取“美化”JSON 的方法。任何帮助表示赞赏。
以下源代码将重现我作为示例给出的初始未美化 JSON 字符串。随意复制/粘贴/编辑。
c# - 以数字作为字段名称的 JsonResult
我需要从我的 ASP.NET MVC 3 应用程序返回一个 JSON 结果,如下所示:
但是我无法创建一个匿名类型的对象,该对象将数字作为字段名称。那么我能做什么呢?
asp.net-mvc - 为 JsonResult 调用 @Html.Action 会更改我在父模板中的响应类型
我有以下控制器:
然后,在里面Index.cshtml
:
我发现,当在我的浏览器中访问这个 url 时,响应内容类型会application/json; charset=utf-8
导致浏览器将 html 呈现为字符串而不是...网页。
解决这个问题的最佳方法是什么?
c# - 如何在 MVC 中的局部视图上返回 json?
我有以下代码:
但是我想在局部视图上使用它,我该怎么做?
asp.net-mvc - 如何在单个 MVC EF 查询中使用 2 个包含语句?
我正在尝试编写一个包含 2 个连接的查询。
- 1 StoryTemplate 可以有多个故事
- 1 个故事可以有多个 StoryDrafts
我开始对 StoryDrafts 对象进行查询,因为这是它链接到 UserId 的地方。
我没有从 StoryDrafts 对象直接到 StoryTemplates 对象的引用。我将如何正确构建此查询?
感谢您的任何帮助。