Hi, Joe
1) EditPost.aspx.cs
String blogFriendlyUrl = "blog" + blog.ModuleId.ToString() + "rss.aspx";
if (!FriendlyUrl.Exists(siteSettings.SiteId, blogFriendlyUrl))
{
FriendlyUrl rssUrl = new FriendlyUrl();
rssUrl.SiteId = siteSettings.SiteId;
rssUrl.SiteGuid = siteSettings.SiteGuid;
rssUrl.Url = blogFriendlyUrl;
rssUrl.RealUrl = "~/Blog/RSS.aspx?pageid=" + pageId.ToString()
+ "&mid=" + blog.ModuleId.ToString();
rssUrl.Save();
}
You forget to specify the PageGuid and culture. Because of this, when you delete a blog procedures mp_Blog_DeleteBySite and mp_Blog_DeleteByModule RSS feed was not removed from the friendly URL
Change the source code to
String blogFriendlyUrl = "blog" + blog.ModuleId.ToString(CultureInfo.InvariantCulture) + "rss.aspx";
if (!FriendlyUrl.Exists(siteSettings.SiteId, blogFriendlyUrl))
{
FriendlyUrl rssUrl = new FriendlyUrl();
rssUrl.SiteId = siteSettings.SiteId;
rssUrl.SiteGuid = siteSettings.SiteGuid;
rssUrl.Url = blogFriendlyUrl;
newFriendlyUrl.PageGuid = blog.BlogGuid;
rssUrl.RealUrl = "~/Blog/RSS.aspx?pageid=" + pageId.ToString()
+ "&mid=" + blog.ModuleId.ToString();
rssUrl.Save();
}
2) PageSetting.aspx.cs
You forget to check the condition that the user can clear the friendly URL:
if ((txtUrl.Text.StartsWith("http"))||(txtUrl.Text == "~/"))
{
pageSettings.Url = txtUrl.Text;
}
else if(friendlyUrlString.Length > 0)
{
pageSettings.Url = "~/" + friendlyUrlString;
}
change to
if ((txtUrl.Text.StartsWith("http"))||(txtUrl.Text == "~/"))
{
pageSettings.Url = txtUrl.Text;
}
else if(friendlyUrlString.Length > 0)
{
pageSettings.Url = "~/" + friendlyUrlString;
}
else if(friendlyUrlString.Length == 0) {
pageSettings.Url = "";
pageSettings.UseUrl = false;
}
and more
if (
(!RedirectInfo.Exists(siteSettings.SiteId, oldUrl))
&& (!RedirectInfo.Exists(siteSettings.SiteId, newUrl))
)
{
RedirectInfo redirect = new RedirectInfo();
redirect.SiteGuid = siteSettings.SiteGuid;
redirect.SiteId = siteSettings.SiteId;
redirect.OldUrl = oldUrl;
redirect.NewUrl = newUrl;
redirect.Save();
}
change to
if (
(!RedirectInfo.Exists(siteSettings.SiteId, oldUrl))
&& (!RedirectInfo.Exists(siteSettings.SiteId, newUrl))
&& (newUrl.Length > 0)
)
{
RedirectInfo redirect = new RedirectInfo();
redirect.SiteGuid = siteSettings.SiteGuid;
redirect.SiteId = siteSettings.SiteId;
redirect.OldUrl = oldUrl;
redirect.NewUrl = newUrl;
redirect.Save();
}
3) Now the case for the blog. The same is not checked for an empty URL
EditPost.aspx.cs
if (!WebPageInfo.IsPhysicalWebPage("~/" + friendlyUrlString))
{
FriendlyUrl newFriendlyUrl = new FriendlyUrl();
newFriendlyUrl.SiteId = siteSettings.SiteId;
newFriendlyUrl.SiteGuid = siteSettings.SiteGuid;
newFriendlyUrl.PageGuid = blog.BlogGuid;
newFriendlyUrl.Url = friendlyUrlString;
newFriendlyUrl.RealUrl = "~/Blog/ViewPost.aspx?pageid="
+ pageId.ToString(CultureInfo.InvariantCulture)
+ "&mid=" + blog.ModuleId.ToString(CultureInfo.InvariantCulture)
+ "&ItemID=" + blog.ItemId.ToString(CultureInfo.InvariantCulture);
newFriendlyUrl.Save();
}
change to
if ((!WebPageInfo.IsPhysicalWebPage("~/" + friendlyUrlString))
&& (friendlyUrlString.Length > 0))
{
FriendlyUrl newFriendlyUrl = new FriendlyUrl();
newFriendlyUrl.SiteId = siteSettings.SiteId;
newFriendlyUrl.SiteGuid = siteSettings.SiteGuid;
newFriendlyUrl.PageGuid = blog.BlogGuid;
newFriendlyUrl.Url = friendlyUrlString;
newFriendlyUrl.RealUrl = "~/Blog/ViewPost.aspx?pageid="
+ pageId.ToString(CultureInfo.InvariantCulture)
+ "&mid=" + blog.ModuleId.ToString(CultureInfo.InvariantCulture)
+ "&ItemID=" + blog.ItemId.ToString(CultureInfo.InvariantCulture);
newFriendlyUrl.Save();
}
4) And even before this code, paste the code to delete the old user-friendly URL (just as you did for PageSettings.aspx.cs)
Later I'll write more about some errors (not critical, but unpleasant)
Best regards, Alexander