c# - Why my MVC client gets null response from WCF Service? -
i have problem asp.net mvc application. in service folder created wcf service this:
iservice.cs
namespace helloworld { [servicecontract] public interface iservice { [operationcontract] list<string> getusers(); } }
service.svc
<%@ servicehost language="c#" debug="true" service="helloworld.service" codebehind="service.svc.cs" %>
service.svc.cs
namespace helloworld { public class service : iservice { private applicationdbcontext db = new applicationdbcontext(); public list<string> users = new list<string>(); public list<string> getusers() { foreach(var item in db.users.tolist()) { users.add(item.username.tostring()); } return users; } } }
after added service reference mvc client , created following action controller:
// post: simpleclient/create [httppost] public actionresult index() { userservice.serviceclient objuser = new userservice.serviceclient(); viewbag.users = objuser.getusers().tolist(); // null return view(); }
but in index view got null value in viewbag. did make mistake?
Comments
Post a Comment