Question

I am trying to get a handle on Solrnet and interacting an ASP.NET site with a Solr server. However, the sample app (on the code repository) is MVC based ,does anyone know of a version in plain vanilla ASP.NET?

Thanks

Was it helpful?

Solution

There aren't any major differences really:

  • Initialize the library in your Application_Start() just like in the MVC sample app.
  • The simplest way to use it in a code-behind is to use the service locator to get the main SolrNet interface (e.g. var solr = ServiceLocator.Current.GetInstance<ISolrOperations<MyDocumentClass>>()), (in MVC it's easy to instead inject the interface using an IoC container)
  • Then you can use that instance to run any query you want, update documents, etc. In the MVC sample app a ModelBinder is used to get the search parameters from the querystring, but that's a MVC feature, so getting the search parameters is up to you.
  • Then bind the query results to the page (I mostly use a simple foreach, you could also try ObjectDataSource)

OTHER TIPS

This is little late. But for people still looking for Solrnet /ASP.NET sample without MVC can look at the following: http://crazorsharp.blogspot.com/2010/01/full-text-search-using-solr-lucene-and.html http://blog.dileno.com/archive/201009/get-started-using-solr-for-search-with-aspnet/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top