<%@ WebHandler Language="C#" Class="Categorias" %> using System; using System.Web; using System.Web.SessionState; using System.Data; public class Categorias : IHttpHandler, IReadOnlySessionState { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; /* ================================================================================= */ /* ================================================================================= */ if (context.Request.ServerVariables["HTTP_REFERER"] == null || context.Request.ServerVariables["HTTP_REFERER"].ToUpper().IndexOf("/ADMINISTRACAO/REQUISICOES/ECONOMATO") < 0) { // REDIRECCIONA PARA A PÁGINA DE LOGIN.aspx // CASO ESTA PÁGINA SEJA ACEDIDA DIRECTAMENTE SEM PASSAR PELO SITE context.Response.Redirect("/login.aspx"); } /* ================================================================================= */ /* UTILIZADOR AUTENTICADO */ try { Intranet.Users intranetUser = (Intranet.Users)context.Session["intranetUser"]; /* ============================================================================= */ /* LISTAGEM DE TODAS AS CATEGORIAS JÁ INSERIDAS */ string _categorias = ""; DataTable dtCategorias = Intranet.Administracao.Economato.Categorias(); for (int i = 0; i < dtCategorias.Rows.Count; i++) { _categorias = _categorias + dtCategorias.Rows[i]["categoria"].ToString() + "\\s"; } context.Response.Write(_categorias); } catch (Exception) { context.Response.Write("erro"); } } public bool IsReusable { get { return false; } } }