Rss 2.0 via FEED
Ken Hughes... - ASPNET
Productivity, Technology and Automating Everything...
    
 

imageOriginally I had my website set up to default to my blog (so dasBlog was installed at the website root level instead of in a /blog subfolder).

Recently I have been writing some Web Applications and wanted to restructure my website so that there is a subfolder for each app / main area (blog, projects, etc).

The problem being that all the links out there point to http://www.kapie.com/blog/somefile.aspx and these would all be dead link when moved to http://www.kapie.com/blog/somefile.aspx, so I needed to respond with a HTTP 302 to the original links and tell the client that it should temporarily redirect to the new location (changing to a HTTP 301 when I am happy that it is all working).

This called for a HttpModule...

namespace KSL
{
     public class BlogRedirector : IHttpModule
     {
VisualStudioLogo         private EventHandler onBeginRequest; 

         public BlogRedirector()
         {
             onBeginRequest = new EventHandler(this.HandleBeginRequest);
         }
 
         void IHttpModule.Dispose()
         {
         }
 
         void IHttpModule.Init(HttpApplication context)
         {
             context.BeginRequest += onBeginRequest;
         }

         private void HandleBeginRequest( object sender, EventArgs evargs )
         {
             HttpApplication app = sender as HttpApplication;
 
             if ( app != null )
             {
                 HttpContext context = app.Context;
                 string host = app.Request.Url.Host;
                 string requestUrl = app.Request.Url.PathAndQuery;

                 if (requestUrl.Contains(@"/blog/") 
                     || requestUrl.Contains(@"/foo1/") 
                     || requestUrl.Contains(@"/foo2/") 
                     || requestUrl.Contains(@"/foo3/")
                     || requestUrl.Contains(@"/foo4/")
                     || (requestUrl.ToLower() == app.Request.Url.Scheme + @"://" + host + @"/default.aspx"))
                 {
                     return;
                 }
                 else
                 {
                     Uri newURL = new Uri(app.Request.Url.Scheme + @"://" + host + @"/blog" + requestUrl);
                     context.Response.RedirectLocation = newURL.ToString();
                     context.Response.StatusCode = 302;
                     context.Response.End();
                     return;
                 }
             }
         }
    }
}

This basically allows me to redirect any url that does not contain /blog/ or /foo*/ or is not /default.aspx by sending a 302 status code and adding /blog/ to the url to generate the redirect url. The compiled DLLs were stored in the bin folder off the root and the web.config in the root needed the following adding...

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <httpModules>
      <add type="KSL.BlogRedirector,BlogRedirector" name="BlogRedirector" />
    </httpModules>
  </system.web>
</configuration>

This seemed to work fine some of the time, but was a bit hit and miss.... Further investigation pointed me at the web.config files in the subfolders and that they would inherit the sections from the root web.config. So all the subfolder web.config files got the following added.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <httpModules>
      <remove name="BlogRedirector" />
    </httpModules>
  </system.web>
</configuration>
GEO 51.4043197631836:-1.28760504722595
Posted: Wednesday, December 19, 2007 7:09:38 PM (GMT Standard Time, UTC+00:00)  #   Comments [0]
TAGS: .NET | ASP.NET | C Sharp | Development | Web

InsertPanel I have just completed a new Windows Live Writer plugin. This extension allows ease insertion of geo microformat information.

It allows the user to easily choose the location they want to insert (in microformat) from a Virtual Earth map and also configure how it is displayed (if at all on the post.

Recently I (with considerable help from Alexander Groß) added GeoRss support for dasBlog. The co-ordinates can be specified when adding a post via the web interface. This plugin is stage two of this support, stage three will be parsing the geo microformat when a post is added and using that to populate the GeoRss info.

The end goal being to allow the geo info to be entered when creating a post in Writer and having that info available in GeoRss format in the feed.

I started this plugin with the view to using Google Maps, however they require that you get an API key and that key is only valid for a particular web site / URL path. This foiled my plans to embed the map in a Windows Forms WebBrowser control (I did look at producing an html page that was served from my web site, and using it embedded in the WebBrowser - not scaleable and too much configuration for a normal user to do.

InsertMicroformat 

I hadn't looked in depth at Virtual Earth, but recently went to MixUK:07 and saw a couple of demos / presentations on it - a quick look found that it didn't need a API and was not tied to a particular URL / path - the JavaScript for it is pretty similar to the one for Google Maps so learning curve was pretty short. The only issue I have with http://local.live.com is that there is no (currently) facility to enter a GeoRss feed in the search query and just display the data (the current method of displaying this kind of data is to embed a map in your own pages and use their API to display the items as a 'collection').

You can get the installer for it here InsertGeoFormatSetup.msi (325Kb).

GEO 51.4043243116043:-1.28760516643523
Posted: Saturday, September 15, 2007 11:12:11 PM (GMT Daylight Time, UTC+01:00)  #   Comments [5]
TAGS: .NET | ASP.NET | C Sharp | Dasblog | GPS | RSS | Web

I have completed stage one of GeoRss enabling dasBlog.

In the config page I added some options for enabling GeoRss, specifying a default lat/long and enabling ‘integration’ with Google maps. There is also an option to use the default lat/long for any non geocoded posts.

  clip_image0022_thumb1

If GeoRss is enabled then the edit entry screen provides textboxes to allow specifying lat/long (populated with defaults from config page).

clip_image00421_thumb2

If the google maps integration is enabled then you’ll get the ‘Show Map’ button and clicking it will display a map which you can move around until you find the location and then click on the location to get the lat/long texboxes populated.

clip_image00681_thumb1

If you have existing non geocoded posts then you can have the default lat/long added to those if you wish.

I puzzled around for ages when trying to display the georss in google (http://maps.google.com/maps?q=yourfeedaddress) – it kept telling me that the feed was invalid. I eventually found that feedburner was adding <atom10:link blah blah /> to the xml which for some reason google maps thinks is invalid. The only way I could find to prevent feedburner adding the atom link was to turn OFF the ‘Browser Friendly’ feature in feedburner.

So – stage 2...

The work I still want to do with this is basically to add macros to get lat/long  - fairly easy I guess, and then some way to specify lat/long from Windows Live Writer (and other offline blog clients) – a little more complex. Scott mentioned a geo microformat and from my initial looks seems to be a good route to take - watch this space...  

Now it is simply a case of retrofitting the geo info into all my old posts...

 

Posted: Saturday, September 08, 2007 10:33:40 PM (GMT Daylight Time, UTC+01:00)  #   Comments [0]
TAGS: .NET | ASP.NET | C Sharp | Dasblog | Development | GPS | RSS | Software

Mixuk I registered for Mix:UK a few weeks ago and today got an email from the Mix team about a social networking tool they are using to help people make the most of the conference.

backnetworkThey are using backnetwork, which allows creation of profiles, blogging, photos, adding friends / colleagues etc (all the usual social networking stuff). It also allows you to add any colleagues / friends automagically from any previous backnetwork events you have been to.

 This is certainly a step in the right direction, but it's missing an 'auto-suggest relationship' feature that could analyze your profile (or tags) and suggest other people who have similar interests.

So... my profile is here, anyone interested in any of my tags feel free to contact me and set up a meeting/chat/lunch/coffee/whatever...

Posted: Tuesday, August 28, 2007 4:51:16 PM (GMT Daylight Time, UTC+01:00)  #   Comments [0]
TAGS: ASP.NET | Development | mixuk07  | Web

dasBlog_image So dasBlog 2.0 (running under AS.NET 2.0 and medium trust) is now released. Scott has a great write up on it.

I have been running this web site on it for a few weeks now and it's been fine. We sneaked in a couple of last minute features (one of mine was a new macro for rendering the navigation links as an Unordered List instead of a table with one cell per row).

I've been spending a fair bit of time on dasBlog recently - extending activity Rss feed and working on georss integration. I have a georss version working with a simple UI allowing the user to specify Lat/Long for each post and then a link to view the feed items in Google maps. I have not checked it in yet as I want to provide a slicker UI for specifying the location (maybe a map that allows you to drag/select the location or enter a zip code and view the location then use that).
I also want to provide options for getting the location in when using blogging clients (Windows Live Writer etc), not just the web based 'add entry' UI.

There is also some great work going on with Clemens Vaster and other really revamping some of the architecture bits and bringing dasBlog to the next level.

Watch this space...

Posted: Thursday, August 16, 2007 2:30:55 PM (GMT Daylight Time, UTC+01:00)  #   Comments [0]
TAGS: .NET | ASP.NET | Dasblog | Development

A few months ago I added a 'Daily Report Email' feature to dasBlog, so I could have the activity reports (referrers, searches etc) delivered to my mailbox at the end of every day.
I wanted to take this one step further and deliver it via RSS (and dasBlog is a RSS engine after all).

There were a couple of suggested methods raised on the dasBlog developers mailing list; one was using HTTP authentication - I was reluctant to use this as Outlook 2007 does not support authorized feeds. The other suggestion was to obfuscate the URL with a Guid or the like - this was my preferred option.

So, I have been working on it over the past few evenings, got it rolled out to this blog and it seems to be working pretty well.

image

I added a checkbox to the site configuration page, that when checked generates a Guid that is used as part of the path. The 'activityrss.ashx' page doesn't exist at that path (in fact it doesn't exist at all!), instead there is a HttpHandler for the file 'activityrss.ashx' that intercepts any requests for that file and does some processing.

In this processing I check that the requested URL contains the Guid and if so, generate the Activity RSS feed. The content of each feed item is the activity report (similar format to the daily report email).

image

NOTE: This is not in a release yet, if you want it you'll have to check out the source, patch it with this patch file and compile, deploy it manually.

 

Posted: Saturday, July 21, 2007 12:18:41 AM (GMT Daylight Time, UTC+01:00)  #   Comments [1]
TAGS: .NET | ASP.NET | C Sharp | Dasblog

One of the projects I am involved with at work was evaluating Microsoft CRM (MSCRM).

Out of the box, it comes as a pretty well fully featured CRM application, but it is also hugely customizable. I downloaded the SDK from here and had a quick play.
Within 20 – 30 minutes I had a quick extension / customisation working – it is a simple webpage allowing customers to register their own details and when submitted, that customer is automatically added to MSCRM.

It was incredibly simple to get working, just :-

  • Create a new web project
  • Add a web reference to MsCrmSdk
  • Add some textboxes and a submit button and on the 'submit click' event just :-
    • Create a new CrmService object
    • Set the URL for it and provide credentials if necessary
    • Create a new contact object
    • Populate it with the data from the textboxes
    • Call 'Create' on the CrmService object passing the contact object as a parameter

You're done...

Below is some sample code – it only picks up a few details about the contact, but should be fairly easy to enhance ... Enjoy

 

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using MsCrmSdk;

 

    public partial class _Default : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            btnInsert.Click += new EventHandler(btnInsert_Click);

 

        }

 

        void btnInsert_Click(object sender, EventArgs e)

        {

            string salutation = txtSalutation.Text;

            string firstName = txtFirstName.Text;

            string lastName = txtLastName.Text;

            string emailAddress = txtEmailAddress.Text;

 

            CrmService svc = new CrmService();

            svc.Url = "http://10.10.121.226:5555/mscrmservices/2006/crmservice.asmx";

            svc.Credentials = new System.Net.NetworkCredential("kenh", "Exchange1", "kennet");

 

            contact newContact = new contact();

            newContact.salutation = salutation;

            newContact.firstname = firstName;

            newContact.lastname = lastName;

            newContact.emailaddress1 = emailAddress;

 

            Guid guidResult = svc.Create(newContact);

 

            txtSalutation.Text = "";

            txtFirstName.Text = "";

            txtLastName.Text = guidResult.ToString();

 

        }

 

    }

Posted: Friday, May 25, 2007 12:38:31 PM (GMT Daylight Time, UTC+01:00)  #   Comments [0]
TAGS: ASP.NET | C Sharp | MSCRM
     
 
 
Copyright © 2008 Ken Hughes. All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.0 UK: England & Wales License.