c# - Returning custom object from Core Web API -
i have following basic controller in c# web api core 1.1.
[produces("application/json")] [route("api/[controller]")] public class testresultscontroller : controller { // get: api/testresults [httpget] public ienumerable<string> get() { return new string[] { "test1", "test2" }; } [httpget("getresults")] public iactionresult getresults() { try { var output = new groupresult { name = "test", number = 1 }; // ienumerable<groupresult> output = testqueries.gettestresults(); return ok(output); } catch (exception ex) { return notfound("invalid result: " + ex.message); } } // get: api/testresults/5 [httpget("{id}", name = "get")] public string get(int id) { return "value"; } // post: api/testresults [httppost] public void post([frombody]string value) { } // put: api/testresults/5 [httpput("{id}")] public void put(int id, [frombody]string value) { } // delete: api/apiwithactions/5 [httpdelete("{id}")] public void delete(int id) { } }
the getresults method 1 having problems with, groupresult basic class created in .net 4.5.2 , reference class in solution. when run localhost:xxxx/api/testresults/getresults 500 error invalid server error, looks not hit method have debug set. when comment out class creation , change ienumerable of string, works fine ?
is there missing...
cheers
ok - added swagger project, can see method listed correctly shows internal server error 500. switching iis express running project iis can see dotnet.exe window. in here after calling method, message displayed not find frameworkmodel.dll (file invalid), in solution targeting framework 4.6.1. after reading this, changed target framework of solution .net core 1.1 .net core 1.0, run , method being triggered though getting system.runtime.serialization.dll not found :-)
Comments
Post a Comment