Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friend

i have i issue,in google index my duplicate url are create but this url redirect my orignal url i have develop this code

VB
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
       ' Code that runs when a new session is started
     

       Dim urldata() As String
       Dim casturl As String
       Dim str As String
       str = Request.RawUrl.ToString
       If str.EndsWith(".aspx") Then
           Exit Sub
       End If
       If Not str.EndsWith(".html") Then
           urldata = Split(str, "=")
           casturl = urldata(urldata.Length - 1).ToString()
           Dim con As New SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings("abc").ConnectionString)
           Dim cmd As New SqlCommand
           con.Open()
           cmd.CommandType = Data.CommandType.Text
           cmd.CommandText = "select catName from pqr where catId IN(select parentId from categories where catId IN(select categoryId from registerdata where navTag='" & casturl & "'))"
           cmd.Connection = con
           Dim geturl As String
           geturl = Convert.ToString(cmd.ExecuteScalar)
           Response.Redirect("http://www.example.com/ads-" & Trim(geturl) & "/" & Trim(casturl) & ".html")
       End If



   End Sub


this code is work only for first time..i am click other link that is not working

plz help me

thank u
Posted

1 solution

do this in Application_BeginRequest event. Session_start depend on session time. it work when session start still to session_end time.
C#
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
       {
           // your codes here
       }
 
Share this answer
 
v2
Comments
Yogesh_Chavan 15-Sep-12 6:42am    
but every request call this method.then increase my page load time.plz get me other solution
Dain Ucak 15-Sep-12 7:01am    
why you do this in global.asax?. cant you do this in your page load or master page load. if you havent any special reason for do this in global.asax do this in your page load before loading page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900