P
Peter Afonin
Hello:
I need to redirect user to another folder (or another site). Usually I put
this code to global.asax:
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim svr As String = LCase(CStr(Request.Url.ToString))
Dim svr2 As String
If InStr(1, svr, "domain1") > 0 Then
svr2 = svr.Replace("domain1", "domain2")
Response.Redirect(svr2)
Else
Response.Redirect(svr)
End If
Catch ex As Exception
Response.Write(ex.Message)
Finally
End Try
(I can also use
Dim svr As String = LCase(CStr(Request.ServerVariables("server_name"))))
It works great as long as I redirect to another ASPX page. However, this
doesn't work (event in global.asax doesn't fire) if I want to redirect to
HTML page or another file. For instance, if user types:
http://domain1.com/page.htm
I want him to go to http://domain2.com/page.htm
In my particular case I want him to be able to download a file, so if I give
him a link like this:
http://domain1.com/file.zip
I want him to download http://domain2.com/file.zip.
Same with just another folder instead of domain.
How would I do this?
I would appreciate your help.
Thank you,
I need to redirect user to another folder (or another site). Usually I put
this code to global.asax:
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim svr As String = LCase(CStr(Request.Url.ToString))
Dim svr2 As String
If InStr(1, svr, "domain1") > 0 Then
svr2 = svr.Replace("domain1", "domain2")
Response.Redirect(svr2)
Else
Response.Redirect(svr)
End If
Catch ex As Exception
Response.Write(ex.Message)
Finally
End Try
(I can also use
Dim svr As String = LCase(CStr(Request.ServerVariables("server_name"))))
It works great as long as I redirect to another ASPX page. However, this
doesn't work (event in global.asax doesn't fire) if I want to redirect to
HTML page or another file. For instance, if user types:
http://domain1.com/page.htm
I want him to go to http://domain2.com/page.htm
In my particular case I want him to be able to download a file, so if I give
him a link like this:
http://domain1.com/file.zip
I want him to download http://domain2.com/file.zip.
Same with just another folder instead of domain.
How would I do this?
I would appreciate your help.
Thank you,