TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rams
NA
40
41.6k
Webservice not able to download the files
Oct 21 2011 10:50 PM
Hi All,
Iam using a webservice to downlad the html, audio and video files from the broadcast server and save it in the relay server after creating the folder, but the file is not getting created and also not able to download the files and iam getting Event 1309 warning stating There is an Internal server error(500). Here is the code below and do guide me on the same :
Dim
strSaveAsFileNameWithPath
As
String
= ConfigurationManager.AppSettings(
"FileEncryptFolder"
) + strFileName
Const
ChunkSize
As
Integer
= 10000
Dim
iStream
As
System.IO.Stream =
Nothing
Dim
iBroadcastStream
As
System.IO.Stream =
Nothing
'Dim bytesFileChunk As Byte()
Dim
FileSize
As
Integer
= 0
'Dim Buffer(ChunkSize) As Byte
Dim
strMutexName
As
String
= strFileName
Dim
strProxyURL
As
String
=
String
.Empty
Dim
iProxyPort
As
Integer
Dim
sCompanyID
As
String
= context.Request.QueryString(
"CID"
)
Dim
BroadcastServerURI
As
String
= ConfigurationManager.AppSettings(
"BroadcastServerURI"
) + strFileName +
"&CID="
+ sCompanyID
If
strSaveAsFileNameWithPath.Contains(
"[COMPANYID]"
)
Then
strSaveAsFileNameWithPath = strSaveAsFileNameWithPath.Replace(
"[COMPANYID]"
, sCompanyID)
End
If
If
Not
ConfigurationManager.AppSettings.Item(
"ProxyURL"
)
Is
Nothing
Then
strProxyURL = ConfigurationManager.AppSettings.Item(
"ProxyURL"
).ToString.Trim
End
If
If
Not
ConfigurationManager.AppSettings.Item(
"ProxyPort"
)
Is
Nothing
Then
iProxyPort =
CInt
(ConfigurationManager.AppSettings.Item(
"ProxyPort"
).ToString.Trim)
End
If
'RelayRemoteFile can create a RACE condition as such use mutex to block subsecutive calls
Using
mutex
As
New
Mutex(
False
, strMutexName)
mutex.WaitOne()
'Const ChunkSize As Integer = 10000
Dim
readLen
As
Integer
= 0
Dim
ncAuthorize
As
NetworkCredential = CredentialCache.DefaultNetworkCredentials
'New NetworkCredential("Username", "Password", "Domain")
Dim
ohttpWebRequest
As
HttpWebRequest =
DirectCast
(WebRequest.Create(BroadcastServerURI), HttpWebRequest)
If
(
Not
String
.IsNullOrEmpty(strProxyURL))
Then
objProxy =
New
WebProxy(strProxyURL, iProxyPort)
objProxy.Credentials = CredentialCache.DefaultNetworkCredentials
ohttpWebRequest.Proxy = objProxy
End
If
ohttpWebRequest.Credentials = ncAuthorize
Dim
ohttpWebResponse
As
WebResponse = ohttpWebRequest.GetResponse()
Dim
Buffer(ChunkSize)
As
Byte
Using
responseStream
As
Stream = ohttpWebResponse.GetResponseStream()
Using
oStream
As
Stream = File.Create(strSaveAsFileNameWithPath)
While
True
readLen = responseStream.Read(Buffer, 0, Buffer.Length)
If
readLen = 0
Then
Exit
While
' EoF
oStream.Write(Buffer, 0, readLen)
End
While
End
Using
End
Using
RelayLocalFile(context, strSaveAsFileNameWithPath)
mutex.ReleaseMutex()
End
Using
Thanks,
Rams
Reply
Answers (
1
)
Multiple Inheritance
Running Two Win Forms at the Beginning of Apps