Reputation: 51
I am trying to write webservices Json in asp.net. This code is working on my local pc. But it is not working on server.
[WebMethod(EnableSession = true)] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public void GetMember() { HttpContext.Current.Response.Write(JsonConvert.SerializeObject(DALMember.GetAll())); }
[NullReferenceException: Object reference not set to an instance of an object.] DOAdverisingModule.AdsModule.context_PostRequestHandlerExecute(Object sender, EventArgs e) +295 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +71
Upvotes: 0
Views: 255
Reputation: 34
First, I would recommend switch to MVC API. Web services are old news, and MVC API will allow you a broader spectrum of usability.
Second, the error that you are getting, is it when you are stepping through the code of the (.ASMX)? -- meaning, can you execute code on your site that calls the web service no problem, its just whatever code you are trying to execute within the web service is failing?
Upvotes: 0