我在razor视图引擎MVC4(.net 4.5)应用程序中加载大型JSON响应表单服务器时出现以下错误
" 使用JSON JavaScriptSerializer进行序列化或反序列化时出错.字符串的长度超过了@ Html.Raw(Json.Encode(jsondata)上的maxJsonLength属性上设置的值 "
我试过在我的web.config中设置MaxJsonLength属性:
configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在发送JSON响应的同时在服务器端尝试跟随.
return new JsonResult()
{
Data = data,
ContentType = contentType,
ContentEncoding = contentEncoding,
JsonRequestBehavior = behavior,
MaxJsonLength = Int32.MaxValue
};
Run Code Online (Sandbox Code Playgroud)
还尝试了列出的解决方案:http://brianreiter.org/2011/01/03/custom-jsonresult-class-for-asp-net-mvc-to-avoid-maxjsonlength-exceeded-exception/.但没有什么对我有用:(
有人可以建议我如何避免这个错误或如何增加杰森响应最大长度?
我想实现分层数据结构(例如Product - > Product 2 ----> Product3,Product 2 ----> Product4)使用实体框架6代码的第一种方法.有几种方法可用,但我认为封闭表方法可以满足我的所有要求.有人可以指导我如何有效地或任何其他替代方案在实体框架6中实施闭包表方法?
任何人都可以指导我如何使用开放式XML文字处理在段落上添加预定义样式吗?我在论坛上尝试了各种解决方案,但对我来说没什么用.这是我想要完成的:
// Create a document by supplying the filepath.
WordprocessingDocument wordDocument = WordprocessingDocument.Create("E:/Test/Executive.Docx", WordprocessingDocumentType.Document);
// Add a main document part.
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
// Create the document structure and add some text.
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph para = body.AppendChild(new Paragraph());
Run run = para.AppendChild(new Run());
run.AppendChild(new Text("Executive Summary"));
if (para.Elements<ParagraphProperties>().Count() == 0)
para.PrependChild<ParagraphProperties>(new ParagraphProperties());
// Get the ParagraphProperties element of the paragraph.
ParagraphProperties pPr = para.Elements<ParagraphProperties>().First();
// Set the value of ParagraphStyleId to …Run Code Online (Sandbox Code Playgroud) 我在使用x editable插件从服务器加载选择选项时遇到问题.选择选项中的数据显示为[对象对象]而不是实际选项.这是我的代码:
<a href="#" id ="status" data-name="group" data-type="select" data-source='@Url.Action("ProductGroups")' data-value="1" class="editable-click" title="Group">Operator</a>
Run Code Online (Sandbox Code Playgroud)
ProductGroups操作从控制器返回以下格式[{"value":1,"text":"Default"}]的 JSON响应.在控制器中,我正在这样做.
public JsonResult ProductGroups()
{
var list = new List<xEditableItem>();
foreach (var item in db.ProductGroups.ToList<ProductGroup>().OrderBy(r=> r.Name))
{
list.Add(new xEditableItem() { value = item.ID, text = item.Name });
}
return Json(list, JsonRequestBehavior.AllowGet);
}
public class xEditableItem { public int value {get;set;} public string text {get;set;} }
Run Code Online (Sandbox Code Playgroud)
我事件尝试手动传递选择选项,但结果是选择列表中的相同[对象对象].
<a href="#" id ="status" data-name="group" data-type="select" data-source='[{"value":1,"text":"Default"}]' data-value="1" class="editable-click" title="Group">Operator</a>
Run Code Online (Sandbox Code Playgroud) 我在用 在我的节点 Js 应用程序中typeorm和typescript。我试图找出为类中的所有函数使用单个数据库连接的方法。例如,我的类有两个函数,并且希望对所有函数使用全局/单个连接,而不是在每个函数中创建一个连接,如下所示:
export class SQLDBService implements IDatabaseService{
private readonly logger = getLogger("SQLDBService");
private connection:Connection;
getConversation(conversationId: string): ConversationEntity {
let conversationEntity = new ConversationEntity();
createConnection(/*...*/).then(async connection => {
let dbObj = await connection.getRepository(ConversationEntity).findOne({
conversationId: Equal(conversationId)
});
if(dbObj)
conversationEntity = dbObj;
});
return conversationEntity;
}
pushWrapUp(conversationId: string, wrapUp: string): void {
createConnection().then(async connection => {
let conversationEntity = await connection.getRepository(ConversationEntity).findOne({
conversationId: Equal(conversationId)
});
if(conversationEntity){
conversationEntity.wrapUp = wrapUp;
conversationEntity.endTime = new Date();
await connection.manager.save(conversationEntity);
}
});
}} …Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×2
jquery ×2
json ×2
ajax ×1
c# ×1
hierarchical ×1
node.js ×1
openxml-sdk ×1
typeorm ×1
typescript ×1
x-editable ×1