-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRedirectFile.ashx.vb
executable file
·96 lines (64 loc) · 2.58 KB
/
RedirectFile.ashx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Imports System.Web
Imports System.Web.Services
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Namespace Ventrian.FileLinks
Public Class RedirectFile
Implements System.Web.IHttpHandler
#Region " Private Members "
Private _filePath As String = Null.NullString
Private _moduleID As Integer = Null.NullInteger
Private _userID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub DoRedirect(ByVal context As HttpContext)
context.Response.Redirect(_filePath, True)
End Sub
Private Sub ReadQueryString(ByVal context As HttpContext)
If (context.Request("Path") <> "") Then
_filePath = context.Server.UrlDecode(context.Request("Path"))
End If
If (context.Request("M") <> "") Then
If (IsNumeric(context.Request("M"))) Then
_moduleID = Convert.ToInt32(context.Request("M"))
End If
End If
If (context.Request("U") <> "") Then
If (IsNumeric(context.Request("U"))) Then
_userID = Convert.ToInt32(context.Request("U"))
End If
End If
End Sub
Private Sub TrackDownload(ByVal context As HttpContext)
Dim objTrackInfo As New TrackInfo
objTrackInfo.TrackDate = DateTime.Now
objTrackInfo.ModuleID = _moduleID
objTrackInfo.Path = _filePath
objTrackInfo.UserID = _userID
objTrackInfo.IPAddress = context.Request.UserHostAddress
Dim objTrackController As New TrackController
objTrackController.Add(objTrackInfo)
End Sub
#End Region
#Region " Event Handlers "
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
ReadQueryString(context)
If (_filePath <> Null.NullString And _moduleID <> Null.NullInteger) Then
TrackDownload(context)
DoRedirect(context)
Else
context.Response.Write("Unable to redirect file")
End If
End Sub
#End Region
#Region " Properties "
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
#End Region
End Class
End Namespace