Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 3.5 Website Programming Problem Design Solution
This is the forum to discuss the Wrox book ASP.NET 3.5 Website Programming Problem Design Solution by Chris Love; ISBN: 978-0-470-18758-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Website Programming Problem Design Solution section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 9th, 2009, 02:22 PM
Authorized User
 
Join Date: Oct 2006
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Question Articles--BrowseArticles

I just downloaded this application, and I also purchased the book. I got it running a few hours ago. (VB) I see the links pointing to the individual article "Title" in the BrowseArticle.aspx page throw a 404 error when clicked.
Why not a direct URL on the querystring, with a categoryID on the BrowseArticle.aspx, rather a SEOFriendlyURL?

Last edited by papalolo22; November 13th, 2009 at 09:33 AM..
  #2 (permalink)  
Old June 8th, 2010, 02:08 PM
Registered User
 
Join Date: Jun 2010
Location: Ciudad Real, Spain
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Apparent bug in URL rewriting

Quote:
Originally Posted by papalolo22 View Post
I just downloaded this application, and I also purchased the book. I got it running a few hours ago. (VB) I see the links pointing to the individual article "Title" in the BrowseArticle.aspx page throw a 404 error when clicked.
Why not a direct URL on the querystring, with a categoryID on the BrowseArticle.aspx, rather a SEOFriendlyURL?
RE: Your Question: Why not have direct URL rather than a SEO Friendly one?:
There are, according to this and another Wrox publication ”Professional Search Engine Optimization with ASP.Net”, strong advantages in having SEO friendly Urls. Briefly they are these:
- There is still a small inherent advantage in Search Engine Rankings
- They are more attention grabbing, when appearing either in search result pages or links from other sites, thereby increasing your “click-through rate” (the rate at which links to your site are clicked on) which also increases your search-engine ranking.

RE: 404 error that you were getting:
The download source code for the VB version would appear to have a bug, which stops these links from working.
I got the same error. The problem seems to be this: In the Helpers.VB Module the following code (from line 434) simply doesn’t work:

Code:
    Public Shared Function SEOFriendlyURL(ByVal vURL As String, ByVal vExtension As String) As String
        If Not String.IsNullOrEmpty(vURL) Then
            Return ReplaceInvalidURLCharacters(vURL, "-").ToLower 'vURL.Replace(" ", "-") & vExtension
            'Return sURL.ToLower
        End If
        Return String.Empty
    End Function

    Public Shared Function ReplaceInvalidURLCharacters(ByVal vURL As String, ByVal vReplacement As String) As String
        'Return RegexReplace(vURL, "<|>|#|%|{|}|^|~|[|]", vReplacement)
        Return RegexReplace(vURL, "[^\w]", vReplacement)
    End Function
Replace the above two routines with:

Code:
    Public Shared Function SEOFriendlyURL(ByVal vURL As String, ByVal vExtension As String) As String
        If Not String.IsNullOrEmpty(vURL) Then
            Dim sURL As String = vURL.Replace("\", "/")
            sURL = ReplaceInvalidURLCharacters(sURL, "-").ToLower & vExtension 'vURL.Replace(" ", "-") & vExtension
            Return sURL.ToLower
            'Return sURL.ToLower
        End If
        Return String.Empty
    End Function

    Public Shared Function ReplaceInvalidURLCharacters(ByVal vURL As String, ByVal vReplacement As String) As String
        'Return RegexReplace(vURL, "<|>|#|%|{|}|^|~|[|]", vReplacement)
        Return RegexReplace(vURL, "[^/|^\w]", vReplacement)
    End Function
This makes sure the Urls get rewritten properly.

Then in TBHBLL\Config\ConfigSection.vb line 19

Code:
    <ConfigurationProperty("devSiteName", DefaultValue:="BeerHouse35")> _
Insert a forward slash to make it

Code:
   <ConfigurationProperty("devSiteName", DefaultValue:="BeerHouse35/")> _
This ensures that the re-written URL gets mapped.

This is a quick fix, although there is probably a tidier way of doing it.

Incidentally, the process of URL rewriting is simplified in Asp.Net 4. (Look at http://weblogs.asp.net/scottgu/archi...-0-series.aspx)

Last edited by adrianwhyte; June 8th, 2010 at 08:54 PM.. Reason: Error
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BrowseArticles.aspx Page Problem mashour BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 November 30th, 2008 07:27 PM
Wrox.com C# articles jminatel C# 2005 0 March 23rd, 2007 08:43 PM
Recent articles not showing on articles page kherrerab BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 December 16th, 2006 10:06 AM
error on articles kherrerab BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 October 4th, 2006 02:42 PM
Categorical Articles Beebs BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 9 May 31st, 2006 10:48 PM



All times are GMT -4. The time now is 03:23 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.