Hi New to stackoverfloow and in need of help, when submitting a form using ajax with javascript disabled, i get the following error:
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type '<>f__AnonymousType1
1[System.String]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1
My code is:
public PartialViewResult SearchLocation(string strSearch)
{
if (Request.IsAjaxRequest())
{
int intNumberOfResults = Weather.GetCity(strSearch).Count();
if (intNumberOfResults == 0)
{
ViewData["intNumberOfWeatherLocations"] = "No Locations Found";
}
else
{
if (intNumberOfResults == 1)
{
ViewData["intNumberOfWeatherLocations"] = intNumberOfResults.ToString() + " " + "location found for:" + " " + strSearch.ToString();
}
else
{
ViewData["intNumberOfWeatherLocations"] = intNumberOfResults.ToString() + " " + "locations found for:" + " " + strSearch.ToString();
}
}
var model = Weather.GetCity(strSearch);
return PartialView("WeatherSearch", model);
}
else
{
return PartialView("WeatherSearch", new { strSearch = strSearch });
}
}
I'm trying to follow along with a book i'm reading and modify the code to suit my needs. Any help would be appreciated John