Last post Feb 25, 2014 01:09 AM by geek@ys
Feb 24, 2014 06:09 AM|Basavaraj C. Wadi|LINK
I have created a web api controller to download the excel file from the SharePoint library. The download of Excel file from SP library works fine when debugging the controller from VS using the inbuilt Cassini server. I have now published the solution to
IIS. Now, when I try to run the application using the machine name, the download happens but not entirely. Only 2KB of the 83KB file is downloaded.
I am using the following code:
using (var httpClient = new HttpClient())
using (var request = new HttpRequestMessage(HttpMethod.Get, requestExcelSPUri))
using (Stream contentStream = await (await httpClient.SendAsync(request)).Content.ReadAsStreamAsync(),
stream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
Please let me know the resolution if anybody faced the same issue.
Feb 24, 2014 09:50 AM|er_abhi|LINK
Probably it has to do with some IIS setting, so you can try looking into it.
Feb 25, 2014 01:09 AM|geek@ys|LINK
Take note of the fact that it works when you run it in Visual Studio, but fails when it is deployed and run from the deployed location.
When code is run in Visual Studio, it is run under your account and credentials. But when it is run on IIS, it is run under an application pool and the application pool is by default run under the web user account.
The default user in the webpool might not have enough grant on the resource or site that you are trying to access.
Create an application pool that is run under a service account and grant that service account access to the resources that you wish to access. Run your application under this application tool.