BlogEngine.Core.Web.HttpHandlers.Foaf.ProcessRequest C# (CSharp) Method

ProcessRequest() public method

Enables processing of HTTP Web requests by a custom HttpHandler that implements the interface.
public ProcessRequest ( HttpContext context ) : void
context System.Web.HttpContext /// An object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests. ///
return void
        public void ProcessRequest(HttpContext context)
        {
            // attempt to grab the username from the URL
            // where URL = www.mysite.com/foaf_admin.axd
            // username = 'admin'
            var filename = context.Request.Url.ToString();
            var name =
                filename.Substring(filename.LastIndexOf("/") + 1).Replace(".axd", string.Empty).Replace(
                    "foaf_", string.Empty).Replace("foaf", string.Empty);

            // if no name is specificied, then grab the first user from Membership
            if (name == string.Empty)
            {
                foreach (MembershipUser user in Membership.GetAllUsers())
                {
                    name = user.UserName;
                    break;
                }
            }

            context.Response.ContentType = "application/rdf+xml";
            this.WriteFoaf(context, name);
        }