I am using solr 7 and solrnet 0.4.0.4001. When I am querying to solr an exception occurs:
An exception of type 'System.Xml.XmlException' occurred in System.Xml.dll but was not handled in user code
Additional information:
Data at the root level is invalid. Line 1, position 1.
using Microsoft.Practices.ServiceLocation;
using SolrApp.Entities;
using SolrApp.Models;
using SolrNet;
using SolrNet.Commands.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace SolrApp.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
// find the service
Startup.Init<Products>("http://localhost:8983/solr/pro");
ISolrOperations<Products> solr = ServiceLocator.Current.GetInstance<ISolrOperations<Products>>();
var entityObj = new testEntities();
var pro = entityObj.Products.Select(x => new Products { Id = x.Id, Name = x.Name }).ToList();
solr.Delete(SolrQuery.All);
solr.AddRange(pro);
// commit to the index
solr.Commit();
return View();
}
public JsonResult Search()
{
ISolrOperations<Products> solr = ServiceLocator.Current.GetInstance<ISolrOperations<Products>>();
var appleProducts = solr.Query(new SolrQuery("*:*"));
List<Products> prodList = new List<Products>();
foreach (Products product in appleProducts)
{
var prod = new Products()
{ Id = product.Id, Name = product.Name };
prodList.Add(prod);
}
return Json("", JsonRequestBehavior.AllowGet);
}
}
}