Hi I Have Method In Web Api Service For Get Personal Image
public HttpResponseMessage GetPersonnelPicture( int personnelId)
{
JamsazERPLiteEntities db = new JamsazERPLiteEntities();
var fingerPrint = db.FingerPrints.FirstOrDefault(c => c.SequenceNumber == fingerNumber && c.MAC == MAC && !c.IsDeleted);
if (fingerPrint != null && fingerPrint.Personnel != null)
{
try
{
var result = new HttpResponseMessage(HttpStatusCode.OK);
FileStream fileStream =
new FileStream(@"\\atlas\Personnel Pictures\" + personnelId + ".jpg",
FileMode.Open);
Image image = Image.FromStream(fileStream);
MemoryStream memoryStream = new MemoryStream();
image.Save(memoryStream, ImageFormat.Jpeg);
result.Content = new ByteArrayContent(memoryStream.ToArray());
result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
memoryStream.Close();
memoryStream.Dispose();
fileStream.Close();
fileStream.Dispose();
return result;
}
catch { }
}
return null;
}
When run Web Service in visual studio 2017 in IIS Express And Send Request From Client Successful (I Test by Postman app From send Request localhost:23254/api/Weight/GetPersonnelPicture/?personnelId=2154
)
But When Publish to Local IIS I Get Flowing Error By Postman Application
{ "Message": "An error has occurred.", "ExceptionMessage": "A null value was returned where an instance of HttpResponseMessage was expected.", "ExceptionType": "System.InvalidOperationException", "StackTrace": " at System.Web.Http.Controllers.ResponseMessageResultConverter.Convert(HttpControllerContext controllerContext, Object actionResult)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__0.MoveNext()" }