Locations of visitors to this page


Onteora Software - September 2007

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

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

© Copyright 2008

Russ Fustinos Tool Shed Tour

Russ Fusino's Tool Shed tour will be making a stop at the Space Coast .Net User Group

When: October 3, 2007 @ 3:00 PM

Where: Eau Gallie Public Library

It's All About The Tools – (It’s AATT! ) Episode One!


When I was a youth, watching my Dad tune up our car… there was a spark plug way in the back and it was really tough to get at using a traditional socket wrench. Then he pulled out this special tool that had a bend in it for just such a situation. My Dad  said… “When you have the right tool for the job, it makes it easy… without the right tool you will struggle and struggle”. How true is that? Sometimes as a developer we struggle, needlessly… if we only knew there was a tool that did a certain function. Many times I will see a tool and say “if I had only know about that I would have been done so much quicker”. Many times in an MSDN Event I will show a tool as part of a larger presentation topic and some folks will come up to me afterwards and say that was the best part because that tool solves a specific problem they had.
Did you ever feel inundated with developer tools? Did you ever feel you are missing something that could make your life easier as a developer and as a power user? There are so many tools available to choose from and it keeps getting tougher to  keep up with. Tool familiarity continues to be one of the top developers challenges. This series of seminars is all about tools for developers, by developers.
Welcome to this new, fresh and original ground breaking MSDN seminar series from Russ’ Tool Shed called … It’s All About The Tools.  This is the first installment of many more to come. This session is tech talk about tools for developers. Join Microsoft Florida Developer Evangelist Russ Fustino for his take on what's hot in the developer's toolbox. There's something here for everyone, from beginners to experts. Oh, by the way, you might want to put your hard hat on for this one!
Don’t miss this event. It’s where It’s AATT! J In this first session you will see demonstrations the following tools and a few more surprises… Fiddler Web Stress Tool IE Developer Toolbar Visual Studio IDE tools
•          code convertors
•          obfuscator
•          snippit manager (and the snippet tool in vista as a bonus)
•          toolbox scratch pad
•          Refactor
Visual Studio Express tool’s
Visual Web Developer Express:
•          Web Administrator
•          Membership and personalization
Visual Express C#
•          XNA Express
Live Services
•          Spaces
•          Live Writer
•          MSDN article on search provider (2007.08)
Silverlight 1.0/1.1 XAML Designer (Expression Blend) Community Tool Web Site Review and top downloaded SDK’s
•          GotDotNet: http://www.gotdotnet.com/team/ide/
•          MSDN Dev Center: http://msdn.microsoft.com/vstudio/downloads/powertoys/
•          CodePlex home: http://www.codeplex.com/Default.aspx
•          Download center and more!

 

Please Register if You plan to attend this event

kick it on DotNetKicks.com

Be the first to rate this post

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

Categories: Events | User Group
Posted by Ken Tucker on Friday, September 21, 2007 6:57 PM
Permalink | Comments (1) | Post RSSRSS comment feed

BlogEngine .Net

        I moved my blog today over to BlogEngine .Net today.  It is a nice blog engine that stores the blog entries in xml.  You can also publish blog entries with windows live writer or Word 2007. 

        To keep my existing links working I added to the rewriter class in the BlogEngine.Core.  I created an xml file which stores the OldUrl and the NewUrl to rewrite to. I store the urls I am rewriting in an xml (rewrite.xml) file in the App_Data directory

In the UrlRewrite class I changed the context_BeginRequest procedure to this.

private void context_BeginRequest(object sender, EventArgs e)
{
  HttpContext context = ((HttpApplication)sender).Context;
  DataSet ds = new DataSet();
  int intStart = context.Request.RawUrl.IndexOf('/', 8) + 1;
  string UrlPart = context.Request.RawUrl.Substring(intStart);
  ds.ReadXml(context.Server.MapPath(@"~/App_Data/rewrite.xml"));
  DataRow[] dr = ds.Tables["Urls"].Select("OldUrl Like '" + UrlPart + "'", null);
  if (dr.Length > 0)
  {
      string s = dr[0]["NewUrl"].ToString();
      if (s.Contains(@"/"))
      {
          // if rewrite path is not in same directory we have to redirect
          context.Response.Redirect(s);
      }
      else
      {
          // we can use repath if in same directory
          context.RewritePath(s);
      }

      return;
  }

  if (context.Request.RawUrl.ToLowerInvariant().Contains(".aspx"))
  {
    if (context.Request.RawUrl.ToLowerInvariant().Contains("/post/"))
    {
      RewritePost(context);
    }
    else if (context.Request.RawUrl.ToLowerInvariant().Contains("/category/"))
    {
      RewriteCategory(context);
    }
    else if (context.Request.RawUrl.ToLowerInvariant().Contains("/page/"))
    {
      RewritePage(context);
    }
    else if (context.Request.RawUrl.ToLowerInvariant().Contains("/author/"))
    {
        string author = ExtractTitle(context, "/author/");
        context.RewritePath("~/default.aspx?name=" + author + GetQueryString(context), false);
    }
    //else if (context.Request.RawUrl.ToLowerInvariant().Contains("/tag.aspx/"))
    //{
    //  string tag = ExtractTitle(context, "/tag.aspx/");
    //  context.RewritePath("~/default.aspx?name=" + tag + GetQueryString(context), false);
    //}
  }
}

The XML file Rewriter.xml in the App_Data directory to store the Urls to rewrite

<?xml version="1.0" standalone="yes"?>
<DocumentElement>
  <Urls>
    <OldUrl>sitemap.aspx</OldUrl>
    <NewUrl>sitemap.axd</NewUrl>
  </Urls>
</DocumentElement>

I also added a webpage rewrite.aspx in the admin/pages directory for editing the Urls

<%@ Page Language="C#" MasterPageFile="~/admin/admin1.master" AutoEventWireup="true" CodeFile="Rewrite.aspx.cs" Inherits="admin_Pages_Rewrite" Title="URL Rewrites" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphAdmin" Runat="Server">
<asp:Label runat="server" ID="lblOld" Text="Old Url" ></asp:Label><asp:TextBox runat="Server" ID="txtOld"></asp:TextBox><br />
<asp:Label ID="Label1" runat="server" Text="New Url" ></asp:Label><asp:TextBox runat="Server" ID="txtNew"></asp:TextBox><br />
    <br />
    <asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Text="Add" /><br />

  <asp:GridView runat="server" ID="gridRewrite" AutoGenerateColumns="false" UseAccessibleHeader="true" Width="100%" HeaderStyle-HorizontalAlign="left">
  <Columns>
    <asp:BoundField DataField="OldUrl" HeaderText="<%$ Resources:labels, OldUrl %>" />
    <asp:BoundField DataField="NewUrl" HeaderText="<%$ Resources:labels, NewUrl %>" />
    <asp:TemplateField HeaderText="<%$ Resources:labels, delete %>">
      <ItemTemplate>
        <a href="?delete=<%# Eval("OldUrl") %>" onclick="return confirm('<%# string.Format(Resources.labels.areYouSure, Resources.labels.delete.ToLower(), Eval("OldUrl")) %>')"><%=Resources.labels.delete %></a>
      </ItemTemplate>
    </asp:TemplateField>
  </Columns>
  </asp:GridView>
</asp:Content>

The code behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;

public partial class admin_Pages_Rewrite : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        string strPath = Server.MapPath("~/App_Data/rewrite.xml");
        ds.ReadXml(strPath);
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["delete"] != null)
            {
                DataRow[] dr = ds.Tables["Urls"].Select("OldUrl ='" + Request.QueryString["delete"].ToString() + "'", null);
                try
                {
                    ds.Tables["Urls"].Rows.Remove(dr[0]);

                }
                catch (Exception)
                {
                    System.Diagnostics.Debug.Print("Not found");
                }
                ds.WriteXml(strPath);
            }
        }
        gridRewrite.DataSource = ds.Tables["Urls"];
        gridRewrite.DataBind();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string strPath = Server.MapPath("~/App_Data/rewrite.xml");
        DataSet ds = new DataSet();
        ds.ReadXml(strPath);
        DataRow dr = ds.Tables["Urls"].NewRow();
        dr["OldUrl"] = txtOld.Text;
        dr["NewUrl"] = txtNew.Text;
        ds.Tables["Urls"].Rows.Add(dr);
        ds.WriteXml(strPath);
        Response.Redirect("rewrite.aspx", true);
    }
}

Be the first to rate this post

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

Posted by ken tucker on Thursday, September 20, 2007 4:08 AM
Permalink | Comments (1) | Post RSSRSS comment feed