Slug Question for trasnlation into VB

Topics: ASP.NET 2.0, Business Logic Layer
Aug 5, 2008 at 5:26 PM
I am trying to customize the BlogEngine for my specific site.  All while rewriting it into VB.  I have most of XML provider's rewriten however, I am hung up on the rewriting of urls from the SLUG.  Can some one advise what this should look like in VB.

private static void RewritePage(HttpContext context, string url)
   string slug = ExtractTitle(context, url);
   Page page = Page.Pages.Find(delegate(Page p)
    return slug.Equals(Utils.RemoveIllegalCharacters(p.Slug), StringComparison.OrdinalIgnoreCase);

   if (page != null)
    context.RewritePath(Utils.RelativeWebRoot + "page.aspx?id=" + page.Id + GetQueryString(context), false);

Thanks for any help in advance.



Aug 5, 2008 at 6:12 PM
Hi, unfortunately you can not declare a function inside of a function in VB, which is done in this method.  For future reference, you can download Visual Basic BlogEngine.Net 1.4 from my blog and just take a look at the source.

For most other delegate functions in Be.Net you can create a shared function and call the list.Find using the addressOf operand.  This paticular method however, needs to be recoded it entirely, as you can not pass the additional slug parameter to the delegate function

To recode this one, use this:

Dim slug as string =  ExtractTitle(context, url)
Dim _page as  Page = nothing
For each P as Page in P Page.Pages
    if slug.Equals(Utils.RemoveIllegalCharacters(p.Slug), StringComparison.OrdinalIgnoreCase) then
      _page = p
      exit for
   end if
 if  page isNot nothing then
      context.RewritePath(Utils.RelativeWebRoot.ToString + "page.aspx?id=" + page.Id.ToString + GetQueryString(context), false)
end if

Aug 5, 2008 at 7:56 PM

Thank you very much for a quick reply.  I will try to implement asap.

Thanks again.