Пример #1
0
        protected override void OnPreRender(EventArgs e)
        {
            // modify the NavigateUrl to include optional user name and channel name
            string channel = _channelName != null ? _channelName : string.Empty;
            string user    = _includeUserName ? Context.User.Identity.Name : string.Empty;

            NavigateUrl = RssHttpHandlerHelper.GenerateChannelLink(NavigateUrl, channel, user);

            // add <link> to <head> tag (if <head runat=server> is present)
            if (Page.Header != null)
            {
                string title = string.IsNullOrEmpty(channel) ? Text : channel;

                Page.Header.Controls.Add(new LiteralControl(string.Format(
                                                                "\r\n<link rel=\"alternate\" type=\"application/rss+xml\" title=\"{0}\" href=\"{1}\" />",
                                                                title, NavigateUrl)));
            }

            base.OnPreRender(e);
        }
Пример #2
0
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            _context = context;

            // create the channel
            _channel = new RssChannelType();
            _channel.SetDefaults();

            // parse the channel name and the user name from the query string
            string userName;
            string channelName;

            RssHttpHandlerHelper.ParseChannelQueryString(context.Request, out channelName, out userName);

            // populate items (call the derived class)
            PopulateChannel(channelName, userName);

            // save XML into response
            XmlDocument doc = _channel.SaveAsXml();

            context.Response.ContentType = "text/xml";
            doc.Save(context.Response.OutputStream);
        }