db에서 데이터를 읽는 MVC 페이지가 있습니다. 또한 페이지에서 일부 이미지 링크를/MyController/Photo 또한 db를 읽습니다. 이제 사진이 브라우저에 의해 반입되고있다 "동시에"그래서 나는 몇 장의 사진이 표시되지 않습니다 통지하고 또한 몇 가지 오류 로그 : 뷰에서 :엔티티 프레임 워크 오류 - 동시 db 읽기
다음System.NullReferenceException Object reference not set to an instance of an object.
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open()
......
내 코드입니다 컨트롤러 액션에서
<img src="@Url.Action("Photo", "Profile", new { type = "listing", uID = f.uID })" />
:
public ActionResult Photo(string type, int uID)
{
User u = null;
if (uID == 0)
u = Repository.repository.GetUserByName(User.Identity.Name);
else
u = Repository.repository.GetUserByID(uID);
if (u != null)
{
...
}
}
내 질문은 어떻게 나는 이러한 오류를 얻을하지 않습니다 확인하기 위해 컨텍스트에 엔티티 프레임 워크에 대한 액세스를 동기화 할 수 있습니까?
정적 데이터 인터페이스/저장소를 사용하고 있습니까? –