1
환경에 실패합니다.다중 서버 환경
먼저 내 코드에서 HttpContext.Current.Session에 객체를 저장하고 나중에 다시 읽으려고합니다. 읽은 (여러 번 수행 한) 임의로 실패하고 나는 그 서버가 호출하는 서버와 관련이 있다고 의심합니다. 객체의 저장 및 읽기는 ajax 호출을 통해 수행되며 동료는 Page_Load에 객체를 저장하라고 말했습니다. 나는 상당히 회의적이었고이 문제를 해결하기 위해이 방법을 사용하지 않았다.
보관 :
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public Stream GetHierarchy(string invId, string zoomLevel)
{
Hierarchy hierarchy = new Hierarchy();
try
{
hierarchy = businessLogic.GetHierarchy(invId);
HttpContext.Current.Session["hierarchy"] = hierarchy;
}
catch (Exception ex)
{
throw ex;
}
return new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(hierarchy)));
}
읽기 :
사람이 문제가 어떤 종류의 이상이 되거 수
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public Stream GetCustomer(string invId, string includeDetails, string zoomLevel)
{
Hierarchy hierarchy = (Hierarchy)HttpContext.Current.Session["hierarchy"];
Customers customers = null;
Customer customer = null;
if (hierarchy != null) {
customers = hierarchy.Customers;
if (customers != null)
{
try
{
customer = (from e in customers.DiagramCustomers where e.InvId == invId select e).ToList()[0];
}
catch (Exception ex)
{
}
}
}
return new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(customer)));
}
모든 단일 서버 환경에서 잘 작동하고 ... 그 내가 여기서 마주 치고 있니? 그리고 바람직 Asp.NET 세션 상태를 저장하는
./CJ
당신이 데이터베이스에 필요한 값을 저장하는 옵션이 있습니까 모든 서버에서 액세스 할 수 있습니까? – awright18
일종의 메모리 캐시를 사용해야하고 여러 컴퓨터에서 액세스 할 수 있습니다. – awright18
@ awright18 :하지만 서버 중 하나에서만 세션을 사용할 수있는 서버 클러스터를 갖는 것이 합리적입니까? – CJe