Esempio n. 1
0
        public void ProcessRequest( HttpContext context )
        {
            // get feed format
            if (context.Request["format"] != null)
                format = context.Request["format"].ToString();
            else
                format = "rss";

            // get return count (default 20)
            if ( int.TryParse( context.Request["count"], out count ) == false )
            {
                count = 20;
            }

            // get object type
            if ( context.Request["type"] != null )
                type = context.Request["type"].ToString();

            // get object key
            int.TryParse( context.Request["key"], out key );

            context.Response.Clear();

            if ( type != string.Empty )
            {
                string errorMessage = string.Empty;
                string contentType = string.Empty;

                BlogService blogService = new BlogService();
                string feedXml = blogService.ReturnFeed(key, count, format, out errorMessage, out contentType);

                if ( errorMessage == string.Empty )
                {
                    context.Response.ContentType = contentType;
                    context.Response.Write( feedXml );
                }
                else
                {
                    context.Response.ContentType = "text/html";
                    context.Response.Write( errorMessage );
                }

                context.Response.End();
            }
            else
            {

                context.Response.ContentType = "text/html";

                context.Response.Write( "No Feed Type Provided." );

                context.Response.End();
            }
        }