http post - API controller can't work with new constructor -



http post - API controller can't work with new constructor -

i have method api controller

public class photocontroller : apicontroller { public iphotoservice _photoservice; public photocontroller() { _photoservice = new photoservice(); } [httppost] [route("photo/upload/{photo}")] public bool uploadpicture() { seek { var httprequest = httpcontext.current.request; jobject param = jobject.parse(httpcontext.current.request.params["photo"]); var path = "../" + utils.randomgenerator() + utils.randomgenerator() + "." + httprequest.files[0].filename.split('.').last(); var postedfile = httprequest.files[0]; var filepath = httpcontext.current.server.mappath(path); postedfile.saveas(filepath); _photoservice.uploadphoto(param, path); homecoming true; } grab (exception ex) { homecoming false; } } }

if remove block of code

public iphotoservice _photoservice; public photocontroller() { _photoservice = new photoservice(); }

it work whenever create service api method can't work

on client console print out error

post localhost:17699/photo/upload/%7bphoto%7d 500 (internal server error)

i don't know why because others api controller can work smooth.

i've searched, cleaned , built project...etc...

can guys help me please

http-post asp.net-apicontroller

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -