Problem clients are the ones you like and who ask you about stuff you want to fix, whether you're billing them or not. Loyalty, friendship, or me just being a putz, I don't know. But this was an interesting dotText issue so I had to investigate.
Seems certain robots or browsers (I don't know the exact circumstances) were adding a slash to the end of a dotText categories RSS URLs.
http://myblog.com/category/1/rss became http://myblog.com/category/1/rss/ and generated a "Resource Cannot be Found" error.
ScottW had the final slash covered two years ago, I mean, there's a WebPathStripper class with a RemoveRssSlash(string url) method to make sure a correct URL is being generated! What else can he be expected to do?
What we needed was a simple way to detect the final slash and get rid of it. Here's the fix.
The original RemoveRssSlash(string url) looks like this:
public static string RemoveRssSlash(string url)
{
return Regex.Replace(url,"/rss$",string.Empty);
}
Change it to the following to detect the final slash:
public static string RemoveRssSlash(string url)
{
if (url.EndsWith("/"))
url = url.Substring(0,url.Length - 1);
return Regex.Replace(url,"/rss$",string.Empty);
}
Okay, now we have to modify the HttpHandler pattern for categories in the web.config. If you have supplemental category types (like "terms", "taxonomy", etc, those lines have to updated as well.)
Add a "/?" to the regex pattern, or change
<HttpHandler pattern = "^(?:\/(\w|\s|\.)+\/category\/(\d|\w|\s)+\.aspx/rss)$" type=... to
<HttpHandler pattern = "^(?:\/(\w|\s|\.)+\/category\/(\d|\w|\s)+\.aspx/rss/?)$" type=...
This will cause all URLs ending in "/rss/" to be handled by the RssCategoryHandler class along with the properly structured "/rss" URLs. Bake at 350-degrees in a pre-heated oven for 45 minutes and you have a delicious URL to be enjoyed by the entire HTTP consuming family!