I have followed below link to create a ajax enabled service in my project https://msdn.microsoft.com/en-us/library/bb924552(v=vs.110).aspx
My Asp.Net web forms project has multiple forms in different folders. The admin folder contains form for administration. I created wcf service from the admin folder and the code is as follows
namespace App.secure.Admin
{
[ServiceContract(Namespace = "App.secure.Admin")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Admin
{
[OperationContract]
public string updateComp(string city, string desc )
{
In my webform, I could not add seperate ScriptManager, as I already had ToolkitScriptManager in the form.
I have added the service reference as follows
<ajx:ToolkitScriptManager runat="server" ID="sm1">
<Services>
<asp:ServiceReference Path="Admin.svc" />
</Services>
</ajx:ToolkitScriptManager>
when I am trying to call the wcf service call, it is not able to instantiate the class in wcf service
function UpdateStudent(e) {
city = $("#spnCity").text();
desc = $("#txtDescEd").val();
var service = new App.secure.Admin.Admin();
service.updateComp(city, desc);
}
When I run the application
Unhandled exception in http://localhost/secure/Admin/Add.aspx
0x800a1391 - JavaScript runtime error: 'App' is undefined
I have tried moving the WCf service to the root folder and tried calling it, but it was giving the same error.
The add.aspx.cs file, I am using
namespace App.secure
{
public partial class Add : System.Web.UI.Page
The web.config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="App.AdminSvcAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="App.secure.Admin.AdminAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="App.AdminSvc">
<endpoint address="" behaviorConfiguration="App.AdminSvcAspNetAjaxBehavior" binding="webHttpBinding" contract="App.AdminSvc" />
</service>
<service name="App.secure.Admin.Admin">
<endpoint address="" behaviorConfiguration="App.secure.Admin.AdminAspNetAjaxBehavior" binding="webHttpBinding" contract="App.secure.Admin.Admin" />
</service>
</services>
</system.serviceModel>
</configuration>
Thank you