, 당신은 파일 (사용자 정의 로그의 종류)로 출력 세션 객체의 내용을 것 루틴을 작성할 수 있습니다.
//Controller Action where you store some objects in session
public ActionResult Index()
{
var myObj = new { strTest = "test string", dtTestValue = DateTime.Now, listTest = new List<string>() { "list item 1", "list item 2", "list item 3" }};
Session["test1"] = "Test";
Session["test2"] = myObj;
return View();
}
//Controller Action where you output session objects to a file
[HttpPost]
public ActionResult Index(FormCollection form)
{
//Routine to write each sessionObject serialized as json to a file
foreach (string key in Session.Keys)
{
var obj = Session[key];
JavaScriptSerializer serializer = new JavaScriptSerializer();
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\CustomAspNetLog.txt", true))
{
file.WriteLine(DateTime.Now.ToString() + "\t" + serializer.Serialize(obj));
}
}
return View();
}
자주 그 루틴을 호출해야하는 경우, 당신은 몇 가지 헬퍼 클래스에 넣어 수 있고 당신이 당신의 컨트롤러 행동 할 때마다 호출. 그런 다음 필요한 모든 단계에서 세션 내의 실제 데이터를 검사 할 수 있습니다. KSeen
은 StateServer 즉 분산 캐시 공급자보다는 세션을 저장하는 더 나은 옵션이 있습니다
내가 제안한 것을 시도해볼 수 있겠습니까? –
@ Arno2501 죄송합니다, 이것은 내가 필요한 것이 아닙니다. 어쨌든 당신의 답변에 감사드립니다. – kseen
오 확인 문제는 당신이해야 할 수도 있습니다 이해하지 않습니다하지만 –