Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
0
Answer
Service undefined error using Ajax while attepting to access Bing 2.0 API
Brandon Prescott
15y
4.9k
1
Reply
When I attempt to call Bing 2.0 API from clientside javascript I get this error: Microsoft JScript runtime error: 'BingSearchWithAjax' is undefined Can anyone help clue me in to what I'm doing wrong? The steps I took are as follows: Open Visual Studio 2008 Click File->New->Website choose Web site with ASP.NET 2.0 Web Site template rename default.aspx to BingAjaxClient.aspx ensure code behind file class name matches new Inherits:BingAjaxClient Add reference to Bing 2.0 API as described here: http://msdn.microsoft.com/en-us/library/dd250965.aspx Add new WCF Ajax service: Right click project name and choose Add New Item from the context menu that appears select Ajax-enabled WCF Service give it the name BingSearchWithAjax.svc and click Add it will add a code behind file to the App_Code folder named BingSearchWithAjax.cs add the following code to the BingSearchWithAjax.cs file: using System; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Activation; using System.ServiceModel.Web; // import Bing API using Bing.API; //normally net.bing.api; using System.Collections.Generic; [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class BingSearchWithAjax { [OperationContract] public List
Search(string query) { BingService srchClient = new BingService(); SearchRequest req = new SearchRequest(); req.AppId = "D4CE339EAFDAA4903E7499C24ADDF81E55DD6BDB"; req.Query = query; req.Market = "en-us"; req.Sources = new SourceType[] { SourceType.Web }; req.Adult = AdultOption.Moderate; req.Web = new WebRequest(); req.Web.Options = new WebSearchOption[] { WebSearchOption.DisableHostCollapsing, WebSearchOption.DisableQueryAlterations }; SearchResponse srchResponse = srchClient.Search(req); // create links based on the search results List
li = new List
(); Console.WriteLine("result"); foreach (WebResult res in srchResponse.Web.Results) { LinkInfo link = new LinkInfo(); link.url = res.Url; link.title = res.Title; li.Add(link); } return li; } [DataContract] public class LinkInfo { [DataMember] public string url { get; set; } [DataMember] public string title { get; set; } } } add the following code to the BingAjaxClient.aspx form: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="BingAjaxClient.aspx.cs" Inherits="BingAjaxClient" %>
Ajax-Enabled Bing Search
Ajax-Enabled Bing Search Client
Thanks, Brandon Prescott
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Asynchronous Webservice calls doesn't maintain unique state.
URL Rewriting/Redirecting for WebService(s) using HttpHandler renders blank page