简体   繁体   English

没有MVC的Solrnet /ASP.NET示例

[英]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. 我试图在Solrnet上获取一个句柄,并与Solr服务器交互一个ASP.NET站点。 However, the sample app (on the code repository) is MVC based ,does anyone know of a version in plain vanilla ASP.NET? 但是,示例应用程序(在代码存储库上)是基于MVC的,有人知道纯ASP.NET中的版本吗?

Thanks 谢谢

There aren't any major differences really: 确实没有任何主要区别:

  • Initialize the library in your Application_Start() just like in the MVC sample app. 就像在MVC示例应用程序中一样,在Application_Start()中初始化库。
  • 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) 在代码隐藏中使用它的最简单方法是使用服务定位器来获取主SolrNet接口(例如var solr = ServiceLocator.Current.GetInstance<ISolrOperations<MyDocumentClass>>() ),(在MVC中,很容易代替使用IoC容器注入接口)
  • 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. 然后,您可以使用该实例运行所需的任何查询,更新文档等。在MVC示例应用程序中,使用ModelBinder从查询字符串中获取搜索参数,但这是MVC功能,因此获取搜索参数取决于您。
  • Then bind the query results to the page (I mostly use a simple foreach, you could also try ObjectDataSource) 然后将查询结果绑定到页面(我主要使用简单的foreach,也可以尝试ObjectDataSource)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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