I am creating an ASP.NET mVC site where I am using Lucene.Net for search queries . I told about how to properly configure Lucene Net in an ASP.NET MVC application and it was said that the best method was declared as my IndexWriter
as public static
To do it, so that it can be used again.
Here are some code that is at the top of my SearchController:
public static string index location = server. MapPath ("~ / lucene"); Public stable Lucene.Net.Analysis.Standard.StandardAnalyzer Analyzer = New Lucene.Net.Analysis.Standard.StandardAnalyzer (); Public stable index author = new index indicator (index location, analyzer);
As author
is constant, index space
must also be static. Thus, the compiler is giving me the following error for the Server.MapPath ()
:
, an object reference required for non-static fields, method or property Is 'System.Web.Mvc.Controller.Server.get'
Is there a way to use server? Some of MapPath () or some static fields ? How can I fix this error?
Thank you in advance. Try
, which is still
.
To confirm this, see a question that HostingEnvironment.MapPath
returns the same code as the server .MapPath
:
Comments
Post a Comment