A
Ankit Aneja
I put the code for url rewrite in my Application_BeginRequest on global.ascx
some .aspx pages are in root ,some in folder named admin and some in folder
named user
aspx pages which are in user folder are using this code of url rewrite
project is running completely fine on localhost
but after uploading first page
(http://emailware.net.temporary.domain.name/user/index.aspx) is fine
but as i click
123 Easy-CD Ripper
new page is to be opened using the url rewrite code which is not getting
opened
for debugging
i put line for alert box in Application_BeginRequest
it gives alert box on each page request on local host
but after uploading only on first as i click 123Easy-CD Ripper
it doen't give alert box this time
i.e code in Application_BeginRequest is not getting executed
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
Response.Write("<script language=jscript>alert('" & "inside appbegin
request" & "')</script>")
Dim Context As HttpContext = HttpContext.Current
Dim oldpath As String = Context.Request.Path.ToLower()
Dim lastpath() As String = Split(oldpath, "/")
Dim laname As String = lastpath.GetValue(lastpath.Length - 2)
Dim token As String = "/category/"
Dim i As Integer = oldpath.IndexOf(token)
Dim len As Integer = token.Length
If i <> -1 Then
Dim j As Integer = oldpath.IndexOf("/index.aspx")
If j <> -1 Then
Dim strName As String = oldpath.Substring(i + len, j - (i + len))
Dim id As Integer
id = database.getId(laname)
Dim navpath() As String = database.navigation(id)
Dim Newpath As String = oldpath.Replace(token & strName & "/index.aspx",
"/user/home.aspx?action=1&cid=" & id)
Context.RewritePath(Newpath)
End If
End If
token = "-"
i = oldpath.IndexOf(token)
Dim proIndex As Integer = oldpath.IndexOf("/category")
len = token.Length
If i <> -1 Then
Dim j As Integer = oldpath.IndexOf(".aspx")
If j <> -1 Then
Dim strLid As String = oldpath.Substring(i + len, j - (i + len))
Dim strold As String = oldpath.Substring(proIndex, i - proIndex) & "-"
Dim NewLidpath As String
NewLidpath = oldpath.Replace(strold & strLid & ".aspx",
"/user/moreinfo.aspx?lid=" & strLid)
Context.RewritePath(NewLidpath)
End If
End If
token = "/type/"
i = oldpath.IndexOf(token)
len = token.Length
If i <> -1 Then
Dim j As Integer = oldpath.IndexOf(".aspx")
If j <> -1 Then
Dim strName As String = oldpath.Substring(i + len, j - (i + len))
Dim typepath As String
typepath = oldpath.Replace(token & strName & ".aspx",
"/user/type.aspx?ptype=" & strName)
Context.RewritePath(typepath)
End If
End If
End Sub
some .aspx pages are in root ,some in folder named admin and some in folder
named user
aspx pages which are in user folder are using this code of url rewrite
project is running completely fine on localhost
but after uploading first page
(http://emailware.net.temporary.domain.name/user/index.aspx) is fine
but as i click
123 Easy-CD Ripper
new page is to be opened using the url rewrite code which is not getting
opened
for debugging
i put line for alert box in Application_BeginRequest
it gives alert box on each page request on local host
but after uploading only on first as i click 123Easy-CD Ripper
it doen't give alert box this time
i.e code in Application_BeginRequest is not getting executed
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
Response.Write("<script language=jscript>alert('" & "inside appbegin
request" & "')</script>")
Dim Context As HttpContext = HttpContext.Current
Dim oldpath As String = Context.Request.Path.ToLower()
Dim lastpath() As String = Split(oldpath, "/")
Dim laname As String = lastpath.GetValue(lastpath.Length - 2)
Dim token As String = "/category/"
Dim i As Integer = oldpath.IndexOf(token)
Dim len As Integer = token.Length
If i <> -1 Then
Dim j As Integer = oldpath.IndexOf("/index.aspx")
If j <> -1 Then
Dim strName As String = oldpath.Substring(i + len, j - (i + len))
Dim id As Integer
id = database.getId(laname)
Dim navpath() As String = database.navigation(id)
Dim Newpath As String = oldpath.Replace(token & strName & "/index.aspx",
"/user/home.aspx?action=1&cid=" & id)
Context.RewritePath(Newpath)
End If
End If
token = "-"
i = oldpath.IndexOf(token)
Dim proIndex As Integer = oldpath.IndexOf("/category")
len = token.Length
If i <> -1 Then
Dim j As Integer = oldpath.IndexOf(".aspx")
If j <> -1 Then
Dim strLid As String = oldpath.Substring(i + len, j - (i + len))
Dim strold As String = oldpath.Substring(proIndex, i - proIndex) & "-"
Dim NewLidpath As String
NewLidpath = oldpath.Replace(strold & strLid & ".aspx",
"/user/moreinfo.aspx?lid=" & strLid)
Context.RewritePath(NewLidpath)
End If
End If
token = "/type/"
i = oldpath.IndexOf(token)
len = token.Length
If i <> -1 Then
Dim j As Integer = oldpath.IndexOf(".aspx")
If j <> -1 Then
Dim strName As String = oldpath.Substring(i + len, j - (i + len))
Dim typepath As String
typepath = oldpath.Replace(token & strName & ".aspx",
"/user/type.aspx?ptype=" & strName)
Context.RewritePath(typepath)
End If
End If
End Sub