?
Solved

How do I send large file via Web Service

Posted on 2008-01-24
4
Medium Priority
?
1,940 Views
Last Modified: 2010-04-21
I want to send some videos up to my web server, but it seems that the way I'm sending them now has a limitation of 3072k (because any file larger than that fails).

Below is the code that I call from and to.  This all works fine when it comes any other file (under the 3072k file size).

The ex.message propert when the error occurs (denoted in the code snippet) is as follows:  The underlying connection was closed: An unexpected error occurred on a receive.

So, what I need is code to send a file, and then how to receive it back on the web service side.
'*** NOTE, I DIDN'T DECLARE EVERYTHING I USED BECAUSE I JUST COPIED AND PASTED THE IMPORTANT BITS ***
 
'*** ON THE WEB APP ***
<WebMethod()> _
 Public Function SendImage(ByVal aoImageByte() As Byte, ByVal asFilename As String) As String
	Dim sRet as String = ""
	Dim oImage As System.Drawing.Image = Nothing
 
	Try
		Dim oFS As IO.FileStream
		Try
			oFS = File.OpenWrite(sUploadFolder & "\" & asFilename)
			Try
				oFS.Write(aoImageByte, 0, aoImageByte.Length)
			Catch ex As Exception
				sRet = "* ERROR: " & ex.Message
			End Try
 
			oFS.Close() : oFS.Dispose() : oFS = Nothing
	Catch ex As Exception
		sRet = "* ERROR: " & ex.Message
	End Try
 
	Return sRet
End Function
 
'*** SUB BELOW IS WHAT I USE TO CALL THE WEB REFERENCE IN A VB.NET APP ***
 
'*** WEB REFERENCE ***
Dim coProcessImage As New WRProcessImages.ProcessImages
 
Private Sub SendFile
	Dim oFS As FileStream, sRet as String = ""
	
	Try
		oFS = File.OpenRead(oMyImage.Folder & "\" & oMyImage.Filename)
 
		Dim bImageByte(oFS.Length - 1) As Byte
 
		oFS.Read(bImageByte, 0, oFS.Length)
 
		'**** HERE IS WHERE I GET THE EXCEPTION EVERY TIME IF FILE SIZE IS OVER 3072k
		Try
			sRet = coProcessImage.SendImage(bImageByte, oMyImage.Filename, 0, "N")
		Catch ex As Exception
			sRet = "WEB SERVICE ERROR: " & sRet
		End Try
 
		bImageByte = Nothing
	Catch ex As Exception
		sRet = "COULD NOT OPEN VIDEO FILE.  FILENAME: " & oMyImage.Filename
	End Try
 
	oFS = Nothing
End Sub

Open in new window

0
Comment
Question by:MarkWThompson
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
athapa earned 2000 total points
ID: 20740049
Change the web.config or machine.config to increase the upload limit on iis.
Check this article.
http://www.c-sharpcorner.com/UploadFile/scottlysle/UploadwithCSharpWS05032007121259PM/UploadwithCSharpWS.aspx
0
 
LVL 1

Expert Comment

by:retechguys
ID: 20740815
You might be runing into a File System limitation.  AKA NTFS file size limit vs Fat32 file size limit.
0
 

Author Closing Comment

by:MarkWThompson
ID: 31424861
Thanks!
0
 

Author Comment

by:MarkWThompson
ID: 20741656
That was exactly it.  I added the snippet below to the web.config file and it worked like a charm.

Thanks!
	<system.web>
		<httpRuntime maxRequestLength="250000"/>

Open in new window

0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question