Dear,I Created web services in ASP.Net, its working fine but how to do the Cross Domain.I wrote below code to get the result in JSON format.<webmethod,> _Public Function GetUserDetails() As StringDim dt As New DataTable()Using conUsing cmd As New OleDb.OleDbCommand("SELECT * FROM Mst_User", con)con.Open()Dim da As New OleDb.OleDbDataAdapter(cmd)da.Fill(dt)Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer()Dim rows As New List(Of Dictionary(Of String, Object))()Dim row As Dictionary(Of String, Object)For Each dr As DataRow In dt.Rowsrow = New Dictionary(Of String, Object)()For Each col As DataColumn In dt.Columnsrow.Add(col.ColumnName, dr(col))Nextrows.Add(row)NextReturn serializer.Serialize(rows)End UsingEnd UsingEnd FunctionI put the code in Web.config fileHide Copy Code
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Content-Type" /> </customHeaders> </httpProtocol> </system.webServer> <system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength="1024242"></jsonSerialization> </webServices> </scripting> </system.web.extensions>
What i need to do more to get the Cross domain.ThanksBasit.