Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Делаю проект MVC + Web API 2. День угробил, но так и не онял, в чем дело. при обращении к методам контроллера в респонс огребается одна и таже фигня... автор{"Message":"An error has occurred.","ExceptionMessage":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.","ExceptionType":"System.InvalidOperationException","StackTrace":null,"InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Error getting value from 'AssignedPhotoAlbum' on 'System.Data.Entity.DynamicProxies.PhotoImage_BEFE2625DE72A4CA4919DEF1173EF711F37B98D60AA1658717F607E91FE1D6F0'.","ExceptionType":"Newtonsoft.Json.JsonSerializationException","StackTrace":" at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"An error occurred while executing the command definition. See the inner exception for details.","ExceptionType":"System.Data.Entity.Core.EntityCommandExecutionException","StackTrace":" at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)\r\n at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()\r\n at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.Execute(MergeOption mergeOption)\r\n at System.Data.Entity.Core.Objects.DataClasses.EntityReference`1.Load(MergeOption mergeOption)\r\n at System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.DeferredLoad()\r\n at System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.LoadProperty[TItem](TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject)\r\n at System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.<>c__DisplayClass7`2.<GetInterceptorDelegate>b__2(TProxy proxy, TItem item)\r\n at System.Data.Entity.DynamicProxies.PhotoImage_BEFE2625DE72A4CA4919DEF1173EF711F37B98D60AA1658717F607E91FE1D6F0.get_AssignedPhotoAlbum()\r\n at GetAssignedPhotoAlbum(Object )\r\n at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"There is already an open DataReader associated with this Command which must be closed first.","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)\r\n at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)\r\n at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)\r\n at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)\r\n at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)\r\n at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\r\n at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)"}}}} ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 01:28 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
что-то совсем плохо с сериализацией в Web API? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 01:29 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
controller Код: c# 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 01:45 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Пышыт же Relic Hunter Error getting value from 'AssignedPhotoAlbum' ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 01:50 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic Hunter, "There is already an open DataReader associated with this Command which must be closed first." в RunExecuteReader. Смотри что там не то. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 02:15 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Monochromatique, Да таблицы PhotoAlbum и PhotoImages связанные. С обычным контроллером проблем не возникало. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 02:17 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Да, с простой таблицей без внешних ключей - работает. А стакими нет. Код: c# 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 02:22 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic Hunter Код: c# 1. А зачем тут virtual? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 02:28 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Monochromatique, Морель была взаимствована из обычного MVC приложения. Все работало как часы. С web api не хочет. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 02:33 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Проблема решена. Нужно прикручивать плоские DTO классы, с уже денормализавованными М-Д свойствами. Подробнее тут... http://www.asp.net/web-api/overview/web-api-routing-and-actions/create-a-rest-api-with-attribute-routing Код: c# 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 03:47 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Не проблема решена не полностью. Плоские объекты заработали. А иерархические? Да и тот контроллер, что генерится скаффолдингом нифига CRUD не работает. WebAPI кто-то пользует? Думал ASP.NET сохранить для бэкенда, но, что-то, не идет. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 20:00 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic Hunter WebAPI кто-то пользует? Пользует. Проблем вообще нет. Вернее была - что по атрибутам сериализатор вытаскивал вообще чуть ли не всю базу, пришлось расставлять [JsonIgnore] ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 20:27 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic HunterНе проблема решена не полностью. Плоские объекты заработали. А иерархические? Да и тот контроллер, что генерится скаффолдингом нифига CRUD не работает. WebAPI кто-то пользует? Думал ASP.NET сохранить для бэкенда, но, что-то, не идет. Всё идёт. Какие ещё иерархические? Дай сериализатору нормальные DTO классы и всё будет оке, зачем мудрить?? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 22:47 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
MonochromatiqueВернее была - что по атрибутам сериализатор вытаскивал вообще чуть ли не всю базу, пришлось расставлять [JsonIgnore] Долбоепизм... Я б уволил. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 22:47 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
hVosttДай сериализатору нормальные DTO классы ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 23:01 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
hVostt, classes Код: c# 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 23:05 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic Hunter, а где DTO? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 23:06 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic Hunter, короче, DTO + AutoMapper ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 23:11 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
hVosttКакие ещё иерархические? наверное которые граф не может быть сериализован, так как циклическая ссылка ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 23:12 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
hVosttRelic Hunter, короче, DTO + AutoMapperКуда послал? Можешь рукой показать? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2015, 23:16 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
hVosttMonochromatiqueВернее была - что по атрибутам сериализатор вытаскивал вообще чуть ли не всю базу, пришлось расставлять [JsonIgnore] Долбоепизм... Я б уволил. Ты Мань на грубость нарываешься. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.11.2015, 00:28 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
MonochromatiqueRelic Hunter Код: c# 1. А зачем тут virtual? авторazy Loading With lazy loading, EF automatically loads a related entity when the navigation property for that entity is dereferenced. To enable lazy loading, make the navigation property virtual. For example, in the Book class: Код: c# 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.11.2015, 00:39 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic HunterMonochromatiqueпропущено... А зачем тут virtual? авторazy Loading With lazy loading, EF automatically loads a related entity when the navigation property for that entity is dereferenced. To enable lazy loading, make the navigation property virtual. For example, in the Book class: Код: c# 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Не надо было так стараться. Я выделил строчку, где virtual не нужен. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.11.2015, 00:44 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
MonochromatiqueТы Мань на грубость нарываешься. А я и не для тебя это сказал. Это долбоебизм и я бы уволил к херам за такое, ещё раз скажу ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.11.2015, 08:49 |
|
||
|
MVC + Web API 2
|
|||
|---|---|---|---|
|
#18+
Relic HunterhVosttRelic Hunter, короче, DTO + AutoMapperКуда послал? Можешь рукой показать? https://www.google.ru/search?q=DTO AutoMapper ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 07.11.2015, 08:50 |
|
||
|
|

start [/forum/topic.php?fid=18&msg=39097141&tid=1356157]: |
0ms |
get settings: |
10ms |
get forum list: |
16ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
39ms |
get topic data: |
9ms |
get forum data: |
3ms |
get page messages: |
75ms |
get tp. blocked users: |
2ms |
| others: | 254ms |
| total: | 414ms |

| 0 / 0 |
