Jean-Marc Amiaud

Upload a binary file through an ASP.NET 2.0 WebService

by on Nov.10, 2010, under ASP.NET, Programmation

It’s possible to upload a large binary file through an ASP.NET 2.0 WebService. 

  1. Declare a service method that take a byte array in argument.
  2. Change the maximum http request size allowed by IIS.
  3. Change the maximum http request size allowed by ASP.NET

Service Method

[code lang= »csharp »]

[WebMethod]
public bool FileUpload (string name, int type, byte[] data)
{
}

[/code]

IIS Configuration

For IIS 6.0, you have to change the metabase.xml file located in C:\Windows\System32\Inetsrv.
Find and set the key AspMaxRequestEntityAllowed with the appropriate value.

ASP.NET Configuration (web.config)

Open the web.config file of your WebService project.
Define the httpRuntime subsection of system.web section like this :

[code lang= »xml »]

<httpRuntime enable="true" maxRequestLength="1073741824" />

[/code]

Warning : The maxRequestLength must to be in Ko.

:, , ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!