Hi Friends,
Today I am going to show how to call cross domain web API using jquery.
For this, open Visual Studio 2013 for Web and click on File menu and click on New Project. This will open New Project popup as below.
In the New Project popup, expand Visual C# and select Web node in the left pane. Select ASP.NET Web Application template in the middle pane and enter the name of a project and click OK.
This will open New ASP.NET Project popup as shown below.
Next, we’ll create a sample model inside the model folder in the Web API solution. Right click on the Model folder from the solution explorer and select Add.
For this walk-through, I am using the Product model.
Now publish the code and host in the IIS with sample IP : 101.13.547.18:8065.
But when you try to call this Web API through other application it will give you no root element found error. To resolve this error jsonp formatter in WebApiConfig.cs file.
Now the final part, create another asp.net application and add the below code in aspx page.
Today I am going to show how to call cross domain web API using jquery.
For this, open Visual Studio 2013 for Web and click on File menu and click on New Project. This will open New Project popup as below.
In the New Project popup, expand Visual C# and select Web node in the left pane. Select ASP.NET Web Application template in the middle pane and enter the name of a project and click OK.
This will open New ASP.NET Project popup as shown below.
Next, we’ll create a sample model inside the model folder in the Web API solution. Right click on the Model folder from the solution explorer and select Add.
For this walk-through, I am using the Product model.
public class Product { public int Id{ get; set; } public string Name{ get; set; }
}
Now right click on Controller folder and add DemoController.
Now publish the code and host in the IIS with sample IP : 101.13.547.18:8065.
But when you try to call this Web API through other application it will give you no root element found error. To resolve this error jsonp formatter in WebApiConfig.cs file.
Now the final part, create another asp.net application and add the below code in aspx page.
No comments:
Post a Comment