登录时,json序列化用户类时提示错误“Self referencing loop detected for property……”,经过5个小时的查找,发现原因可能是,用户类包含了其他类的导航属性(codefirst中用到)导致序列化时出现的循环引用错误

解决办法:将用户类投影到新的表中即可。如下:

  var user = ubll.GetList(u => u.LoginName == userName && u.Password == pwd).Select(u => new
{
u.ID,
u.LoginName,
u.Password,
u.Role,
u.Tel,
u.UserName,
u.DelFlag,
u.Email,
u.Gender,
u.CompanyID,
u.Address,
u.CreateDataTime
}).FirstOrDefault(); string UserData = SerializeHelper.Instance.ToJson(user);//序列化用户实体

  

codefirst mvc Self referencing loop detected for property的更多相关文章

  1. Self referencing loop detected for property 错误

    EF 序列化返回json时 报错:Self referencing loop detected for property 解决方案:在webapiconfig.cs文件中,增加设置: 1.config ...

  2. Request failed with status code 500以及自引用循环Self referencing loop detected for property ‘xx‘ with type

    错误Error: Request failed with status code 500 ,调试前端没问题,后端也没问题,还报错"连接超时" 在Network中找到错误Self r ...

  3. JSON.NET的Self referencing loop detected with type的原因以及解决办法

    模型中有循环引用是很常见的.例如,以下模型显示双向导航属性: : public class Category : { : public Category() : { : Products = new ...

  4. .NET JSON 转换 Error ” Self referencing loop detected for type“

    在进行实体转换为Json格式报错如下图: Self referencing loop detected for property 'md_agent' with type 'System.Data.E ...

  5. EF关于报错Self referencing loop detected with type的原因以及解决办法

    1)具体报错 { "Message": "出现错误.", "ExceptionMessage": "“ObjectContent` ...

  6. Self referencing loop detected with type

    json.net namespace EFDAL{    using System;    using System.Collections.Generic;    using Newtonsoft. ...

  7. c# json 序列化时遇到错误 error Self referencing loop detected for type

    参考网址:http://blog.csdn.net/adenfeng/article/details/41622255 在写redis缓存帮助类的时候遇到的这个问题,本来打算先序列化一个实体为json ...

  8. Json Self referencing loop detected

    Self referencing loop detected......的错误 解决方案: 1 增加  [JsonIgnore]  过滤关联,使其不参与序列化. 这个方法简单粗暴.但是你就没办法获取关 ...

  9. Newtonsoft.Json转换强类型DataTable错误:Self referencing loop detected with type ......

    问题,在使用Newtonsoft.Json对强类型的DataTable进行系列化时会出现循环引用错误 解决办法,不要直接系列化强类型的DataTable,改为 JsonConvert.Serializ ...

随机推荐

  1. 解决phpmailer可以在windows下面发送成功, 在linux下面失败的问题

    谢天谢地...差点因为在linux下面phpmailer发送邮件失败转到了window+IIS... Godaddy的linux服务器无法用phpmailer发送(我用的是网易的邮箱服务器...虽然现 ...

  2. ACM 位运算

    的幂 boolean power2(int x) { return((x&(x-1))==0)&&(x!=0): } For example: #include<stdi ...

  3. python cookbook学习笔记 第一章 文本(1)

    1.1每次处理一个字符(即每次处理一个字符的方式处理字符串) print list('theString') #方法一,转列表 结果:['t', 'h', 'e', 'S', 't', 'r', 'i ...

  4. Good Vim plugin for python [Vim python mode]

    Here I got a very neat plugin for vim which is awesome indeed. It's from youtube years before. So le ...

  5. Quagga添加自己的命令

    参考了王斌的文档:http://down.51cto.com/data/621454 TIP:笔者使用的版本是0.99.20 需求:在接口模式下添加一条"ip ospf enable&quo ...

  6. 深入Java虚拟机:JVM中的Stack和Heap

    在JVM中,内存分为两个部分,Stack(栈)和Heap(堆),这里,我们从JVM的内存管理原理的角度来认识Stack和Heap,并通过这些原理认清Java中静态方法和静态属性的问题. 一般,JVM的 ...

  7. 正则表达式之js检验密码强度

    最近一直在做通行证项目,里面的注册模块中输入密码需要显示密码强度(低中高).今天就把做的效果给大家分享下,代码没有网上搜索的那么复杂,能够满足一般的需求. html 代码如下: <!DOCTYP ...

  8. Python中的各种装饰器详解

    Python装饰器,分两部分,一是装饰器本身的定义,一是被装饰器对象的定义. 一.函数式装饰器:装饰器本身是一个函数. 1.装饰函数:被装饰对象是一个函数 [1]装饰器无参数: a.被装饰对象无参数: ...

  9. Kattis - Peragrams

    Peragrams Photo by Ross Beresford Per recently learned about palindromes. Now he wants to tell us ab ...

  10. Xtrabackup 使用stream输出并压缩备份

    mysql:5.6.29xtrabackup:2.2.10mysql数据目录:/data/mysqlmysql备份目录:/data/dbbak/full #确保有足够的磁盘空间 1.安装依赖 yum ...