asp.net mvc - consuming json wcf service from view in mvc -


i trying store information of "user" table in wcf. , return in json format.when invoking service,i can see entities. question how call service in view.i have tried calling ajax shoots error message :( plzz help

service.svc.cs

namespace jsonwcf {      [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)]// note: can use "rename" command on "refactor" menu change class name "service1" in code, svc , config file together.     public class service1 : iservice1     {         [webinvoke(        method = "post",        responseformat = webmessageformat.json,        bodystyle = webmessagebodystyle.wrappedrequest      )]         public list<userdetails> selectuserdetails()         {             pasdatacontext db = new pasdatacontext();             list<userdetails> results = new list<userdetails>();              foreach (user u in db.users)             {                 results.add(new userdetails()                 {                     userid = u.userid,                      empname = u.empname,                     email = u.emailid,                     username = u.username,                     userrole = u.userrole,                     password = u.password,                     telephone = u .telephone                 });             }             return results;         }     } } 

iservice.cs

namespace jsonwcf {     // note: can use "rename" command on "refactor" menu change interface name "iservice1" in both code , config file together.     [servicecontract]     public interface iservice1     {         [operationcontract]         [webinvoke(method = "post", responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrapped, uritemplate = "users")]          list<userdetails> selectuserdetails();     }     [datacontract]     public class userdetails     {              [datamember]             public string userid         {                 get;                 set;             }          [datamember]         public string password         {                 get;                 set;             }          [datamember]             public string username         {                 get;                 set;             }          [datamember]             public string email         {                 get;                 set;             }          [datamember]         public string empname         {                 get;                 set;             }          [datamember]         public string userrole         {                 get;                 set;             }            [datamember]         public string telephone         {                 get;                 set;             }        } } 

try method without .svc file.m sure u wil gt solution.:)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -