url rewriting

  • Thread starter Thread starter bric
  • Start date Start date
B

bric

I was following this article:

http://www.wwwcoder.com/main/parentid/271/site/2014/68/default.aspx

and I know have a working url rewriter. But it's messy and I have a
worry.

My URL is
http://localhost/artist_page/id/189/artistid/67/
and it rewrites to
http://localhost/artist.aspx?id=189&artistid=67

That's fine. But I was running the debugger and saw something
disturbing.

When I first pull the url I do this:

Dim strURL As String = objHttpApplication.Request.Url.ToString.ToLower

That gives me a strURL with the value:

http://localhost/servererrors/404.aspx?404;http://localhost/artist_page/id/189/artistid/67/

So I use regex to pull the 404 references out at the same time that I
rewrite the string to a normal querystring.

BUT, do I have to worry that it's being identified as 404 even though
the proper page is loading? Is it being identified as 404?

As you might guess, I'm doing this for the search engines and if
they're detecting 404 then that could be a problem.

How can I tell?

thanks,
Brian
 
bric said:
I was following this article:

http://www.wwwcoder.com/main/parentid/271/site/2014/68/default.aspx

and I know have a working url rewriter. But it's messy and I have a
worry.

My URL is
http://localhost/artist_page/id/189/artistid/67/
and it rewrites to
http://localhost/artist.aspx?id=189&artistid=67

That's fine. But I was running the debugger and saw something
disturbing.

When I first pull the url I do this:

Dim strURL As String = objHttpApplication.Request.Url.ToString.ToLower

That gives me a strURL with the value:
http://localhost/servererrors/404.aspx?404;http://localhost/artist_page/id/189/artistid/67/

What event are you using to rewrite the URL? It looks like you're working on
it after ASP.NET has attempted to locate the resource and has failed to find
it.
 
http://localhost/servererrors/404.aspx?404;http://localhost/artist_page/id/189/artistid/67/

What event are you using to rewrite the URL? It looks like you're working on
it after ASP.NET has attempted to locate the resource and has failed to find
it.

As in the article I referenced it's the

Public Sub OnBeginRequest(ByVal s As Object, ByVal e As EventArgs)


Or if you'd prefer to see the whole thing it's a reference in
web.config
..
..
..
<system.web>
<httpModules>
<add name="clsHTTPHandler" type="mymusicuniverse.clsHTTPHandler,
mymusicuniverse" />
</httpModules>

and the class...

Imports System
Imports System.Configuration
Imports System.Text
Imports System.Web

Imports System.Text.RegularExpressions

Public Class clsHTTPHandler
Implements IHttpModule

Public Sub Init(ByVal app As HttpApplication) Implements
IHttpModule.Init
AddHandler app.BeginRequest, AddressOf Me.OnBeginRequest
End Sub

Public Sub Dispose() Implements IHttpModule.Dispose
End Sub

Public Delegate Sub MyEventHandler(ByVal s As Object, ByVal e As
EventArgs)

Public Event MyEvent As MyEventHandler

Public Sub OnBeginRequest(ByVal s As Object, ByVal e As EventArgs)

Dim objHttpApplication As HttpApplication = CType(s, HttpApplication)

Dim strURL As String = objHttpApplication.Request.Url.ToString.ToLower

strURL = Regex.Replace(strURL, "/servererrors/404.aspx\?404\;", "")

if InStr(strURL, "/artist_page/") <> 0 then
'rebuild querystring
end if
end sub

end class
 
As in the article I referenced it's the

Public Sub OnBeginRequest(ByVal s As Object, ByVal e As EventArgs)

<snip>

for those interested:
writing response.status to the page in question gave a "200 OK" so
that was encouraging.

Though I still don't know why the error is coming up in the first
place.

I'd still like to hear if anyone has an idea.
-
Brian
 
Back
Top