Quote:
Originally Posted by papalolo22
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)