Telerik Reporting: Safe handle has been closed

Problem

Saat membuka halaman yang berisi report yang menggunakan Telerik Reporting, muncul error “Safe handle has been closed”.

Analisis*

Saat masuk ReportsController.cs, construct ReportsBaseController.cs, fungsi GetUserIdentity mengambil property dari System.Web.HttpContext.Current.User.Identity. Sedangkan Identity.Name sudah disposed, sehingga tidak bisa diakses.

*) Analisis ini tidak eksklusif sesuai dengan problem yang ditemukan. Menurut saya, problem serupa mungkin saja terjadi dengan root cause yang berbeda.

Solusi

Override fungsi GetUserIdentity, ambil Name nya dari Context.User as Principal, field UserName. Code snippet dapat dilihat bawah ini:

protected override UserIdentity GetUserIdentity()
{
	HttpContext httpContext = HttpContext.Current;
	Principal principal = httpContext.User as Principal;
	UserIdentity userIdentity = new UserIdentity()
	{
		AuthenticationType = User.Identity.AuthenticationType,
		IsAuthenticated = User.Identity.IsAuthenticated,
		Name = principal.UserName
	};
	return userIdentity;
}

Kenji Prahyudi has written 7 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>