RSS Reader


I talked in the past about creating an RSS feed and how it's a fairly easy thing to do. One thing that I didn't really cover (and it might be something that you would like to do), is reading in an RSS feed. Perhaps you want to create an aggregator or blog roll or something. In my case, I was simply creating a better code base for creating feeds and decided I might as well be able to read them as well.

RSS.zip (5.07 kb)

Anyway, the code above can read in a well formatted RSS feed (that adheres to the 2.0 specification anyway). Allows for an easy way to combine feeds, output them, etc. All you need to do is create a Document object pointing to the location of the feed to read it in and use toString to output it back out. Anyway, download the code, leave feedback, and happy coding.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: C# | Web Design
Posted by James Craig on Thursday, July 31, 2008 1:57 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Frustration with Providers


Most of the time when you create a web site, you're going to use forms authentication or maybe windows along with one of the default membership, role, and profile providers. In my current frustrating task, I can't use any of the default providers. I'm stuck creating my own (which is actually fairly easy). However, I was constantly being annoyed by the fact that the Page.User property was not being created at all. Once again, this is extremely easy to fix, all we need to do is create a simple HttpModule:

#region Usings
using System;
using System.Web;
using System.Security.Principal;
using System.Web.Security;
#endregion

namespace PortalCore.Web.HTTPModules.Membership
{
    class Membership:IHttpModule
    {

        #region IHttpModule Members
        public void Dispose()
        {
           
        }

        public void Init(HttpApplication context)
        {
            context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
        }

        void context_AuthenticateRequest(object sender, EventArgs e)
        {
                //Check if the user information is already filled out
                if (HttpContext.Current.User == null || HttpContext.Current.User.Identity==null||string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name)))
                {
                    //Get the user's information here from whatever source
                    string []RoleNames=//Fill out with user's roles from your information
                    FormsIdentity Identity = new FormsIdentity(new FormsAuthenticationTicket(USERSNAME, true, 80000));
                    HttpContext.Current.User = new GenericPrincipal(Identity, RoleNames);
                }
            }
        }
        #endregion
    }
}

All the code above does, is hooks into the application's AuthenticateRequest event.  Every time the application wants to verify that the user is authenticated, it calls this event. So if you wanted, you can do some checking of your own at this point to see if the user is authenticated, redirect him, or deny access for certain pages from here. For our cases though we're just interested to see if the user information is filled out and if not we'll fill it out.  This is done by first loading the user's information, then creating the forms authentication ticket, identity, and user object using that infomation.

Since I don't know how you are saving that information, I can't specify how to load it. It may be that you save the information in a cookie, session data, etc. That is the portion that you will have to figure out yourself. However, the Identity and User code is pretty straight forward once you have that. In this instance we're using forms authentication. We could easily use something else, it doesn't matter. However forms would probably be the easiest. Anyway, hopefully this post puts you on the right track for fixing this issue if you run into it. So try it out, leave feedback, and happy coding.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by James Craig on Monday, July 28, 2008 2:44 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Form Clear Extender


I've been building a lot of forms lately and every single one of them has required a clear button of some description. To be honest, I was sort of sick of writing code to clear each of the forms and I didn't want to add in an extra javascript file to do the work (mainly because I never remember what I called the function and have to look it up constantly). Anyway, to combat this annoyance, I created a new extender for the sole purpose of clearing a form.

FormClearExtender.zip (1.56 kb)

It doesn't clear hidden input items (that way your viewstate and other important items aren't deleted) nor does it do anything to any button that it finds. However all text boxes are cleared, radio, check boxes, etc. are reset to the first item in the list.  I will say that there are definite ways this could be improved (adding default values for various items, specifying a set of controls to check instead of the entire form, etc.). However I wanted to keep this one simple.  All you need to do is set the TargetControlID to the button that you want to be the clear button. Please note though that it doesn't stop the item from posting back to the server. So make sure to turn off submit behavior on the button. Other than that, it's ready to use. So download it, leave feedback, and happy coding.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: AJAX | ASP.Net
Posted by James Craig on Tuesday, July 22, 2008 2:36 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Recent comments

None

Calendar

<<  January 2009  >>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Sponsors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009