views:

249

answers:

1

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

+4  A: 

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)
Mauricio Scheffer
ok thanks, will give that shot. Appreciate your help.
Mikos
@Mauricio Scheffer: It's not terribly difficult to do dependency injection in webforms as well, you just can't (as far as I know) do constructor dependency injection. http://code.google.com/p/autofac/wiki/AspNetIntegration
R0MANARMY
@r0manarmy: exactly; if you can't take control of instantiation you can only *hack around it*. Not the real thing.
Mauricio Scheffer