One of mine looks like this:
<section name="EmailSettingsSectionName"
type="GranadaCoder.Email.Settings.EmailSmtpSetting sHandler,GranadaCoder.Emai
l.Settings" />
or .. if I put in what it is:
<section name="NameOfConfigSectionLaterInConfigFile"
type="MyAssemblyName.Namespace1.Namespace2.MyObjec tName,MyAssemblyName" />
Usually, "MyAssemblyName" is the same thing as MyAssembly.dll , but it
doesn't have to map like that.
Make sure you put in a break point IN
public object Create
somewhere..
Because my experience has been that you cannot "step into" the Create Method
from the outside.
(Microsoft is using reflection to instantiate your custom handler class)
Usually you find a bug or two inside the handler you need to weed out.
"Peter Morris [Droopy eyes software]" <pete@NO_droopyeyes_SPAM.com> wrote in
message news:%2****************@TK2MSFTNGP04.phx.gbl...
using System;
using System.Web;
using System.Xml;
using System.Xml.XPath;
using System.Configuration;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using System.Xml.Xsl;
using System.Reflection;
using System.Runtime.CompilerServices;
public class UrlRewriter : IConfigurationSectionHandler
{
protected XmlNode _oRules = null;
protected UrlRewriter() { }
public string GetSubstitution(string zPath)
{
Regex oReg;
foreach (XmlNode oNode in _oRules.SelectNodes("rule"))
{
oReg = new Regex(oNode.SelectSingleNode("url/text()").Value);
Match oMatch = oReg.Match(zPath);
if (oMatch.Success)
{
return oReg.Replace(zPath,
oNode.SelectSingleNode("rewrite/text()").Value);
}
}
return zPath;
}
public static void Process()
{
UrlRewriter oRewriter =
(UrlRewriter)ConfigurationSettings.GetConfig("syst em.web/urlrewrites");
string zSubst =
oRewriter.GetSubstitution(HttpContext.Current.Requ est.Path);
if (zSubst.Length > 0)
{
HttpContext.Current.RewritePath(zSubst);
}
}
#region Implementation of IConfigurationSectionHandler
public object Create(object parent, object configContext, XmlNode
section)
{
_oRules = section;
// TODO: Compile all Regular Expressions
return this;
}
#endregion
}