Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HttpContext.Current.RewritePath 404 Error

Status
Not open for further replies.

DotNetBlocks

Programmer
Apr 29, 2004
161
US
Hello,
I am realy stuck. I am having a problem with the HttpContext.Current.RewritePath in "Global_BeginRequest". When i try and call a file i always get a 404, but i know thefile is there becuse if i switch to server.tranfer or response.redirect it works perfectly. Plus my path is relative to the root directory. I am so confused why this is not working. Any help would be greatly appreciated.:)

Here is my code. I am using VB 2003
Code:
   Private Sub Global_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.BeginRequest
        ' Fires at the beginning of each request
        Dim strUrl As String = Request.ServerVariables("URL")

              If strUrl.EndsWith("/") Or strUrl.EndsWith("index.aspx") Then


            Dim page As Integer = 1
            If Request("page") <> "" Then
                page = Request("page")
            End If


            With strUrl
                Select Case True
                    Case .EndsWith(".asp")
                        Exit Sub
                        'Case .EndsWith(".aspx")
                        '   Exit Sub
                    Case .EndsWith(".gif")
                        Exit Sub
                    Case .EndsWith(".html")
                        Exit Sub
                    Case InStr(Right(strUrl, 4), ".") = 0 Or .EndsWith("index.aspx")


                        HttpContext.Current.RewritePath("/CJ_API_Directory/test.aspx?page=" & page)
                End Select
            End With
        End If
    End Sub

Babloome
 
your code looks OK to me.

but to debug this try making a simple HttpContext.Current.RewritePath("/CJ_API_Directory/test.aspx?page=" & page) call in an sample ASPX file...


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top