protected void Page_Load(object sender, EventArgs e) { if (null != Request.QueryString["type"] && Request.QueryString["type"] == "build") { JavaScriptSerializer jss = new JavaScriptSerializer(); AjaxContext context = new AjaxContext(); context.Html = string.Empty; try { context.IsSuccess = true; BuildModelsAndPermissions(); } catch (Exception ex) { context.IsSuccess = false; context.Source = ex.Source; context.Message = ex.Message; context.TargetSite = ex.TargetSite.ToString(); context.StackTrace = ex.StackTrace; if (null != ex.InnerException) { context.InnerException = ex.InnerException.ToString(); } } string error = jss.Serialize(context); Response.Write(error); Response.Flush(); Response.End(); } }