I have an ASP.NET framework web application that processes documents and returns it in a template contract. If I send it a smaller document (143KB) it processes fine and sets the template contract properly (ie. template contract is not null): Template set properly for smaller file
If I try a larger file (5MB), it receives the request but the template contract is null: Template contract set to null for larger file
This is the code where the template object is recieved:
[Route("v2/document")]
[HttpPost]
public IHttpActionResult ReportsV2([FromBody] Template template)
{
if (template.Data == null && string.IsNullOrEmpty(template.ConnectionString))
{
if (Log.IsDebugEnabled)
{
LogDebugHeaders();
LogRawIncomingContent();
}
throw new ReportGeneratorException("Template not provided. Specify the Data or Uri element.");
}
So when I use the larger file it hits the conditional statement and throws an error. Ive also added the following lines to the following lines to the web.config but still got the error:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
This is the exception I get:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=RESTfulEngine
StackTrace:
at RESTfulEngine.Controllers.ReportsController.ReportsV2(Template template) in C:\Jenova\restfulengine\RESTfulEngine\Controllers\ReportsController.cs:line 95
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
Any ideas as to why this is happening?
User contributions licensed under CC BY-SA 3.0