2

Closed

SearchRequest Options

description

Hi,
 
I found a minor bug in SearchRequest.cs. In the ToQueryString() method, where you loop through the search options, you seem to cast to the wrong enum.
 
This is the current code:
 
if (Options != null)
{
foreach (ApiHelper.SearchOption option in Options)
{
  request += string.Format("&Options={0}",Enum.GetName(typeof (ApiHelper.WebSearchOption), option));
}
}
 
Instead it should be this:
 
if (Options != null)
{
foreach (ApiHelper.SearchOption option in Options)
{
  request += string.Format("&Options={0}",Enum.GetName(typeof (ApiHelper.SearchOption), option));
}
}
 
In the Enum.GetName, you cast to ApiHelper.WebSearchOption where it should be just ApiHelper.SearchOption. This doesn't lead to any error, but instead the wrong options are sent to the bing API.
 
Regards,
Matthias
Closed May 27, 2010 at 5:06 PM by jguadagno
Made the adjustment to the code.

comments

WorWicWebmaster wrote May 27, 2010 at 4:02 PM

It actually does lead to an error if you set SearchRequest.Options to include ApiHelper.SearchOption.EnableHighlighting. Bing is then sent DisableQueryAlterations for the SearchRequest.Options setting, and it coughs up an error.

wrote May 27, 2010 at 5:06 PM

wrote Feb 14, 2013 at 12:38 AM

wrote May 16, 2013 at 6:09 AM