简体   繁体   中英

Solrnet /ASP.NET sample without MVC

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

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 (eg 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)

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM