Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 135763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:50:31+00:00 2026-05-11T06:50:31+00:00

I have an asp.net mvc project that uses some search methods in a seperate

  • 0

I have an asp.net mvc project that uses some search methods in a seperate library. This library needs to know the location of my lucene index files.

    private static string lucenePath = ConfigurationManager.AppSettings['lucenePath'];      public static ColorList SearchColors(Query query) {         return new ColorList(             new IndexSearcher(Path.GetFullPath(lucenePath)),             query);     } 

This correctly reads my configured lucenePath from the web.config’s application key node. But how can I get the correct full path from this relative path? Path.GetFullPath gives me a completely incorrect path.

–Conclusion–
If you want to go full-out, tvanfosson‘s answer is probably for you.
I, however, kept it a little more brain dead by using the following:

Path.Combine(AppDomain.CurrentDomain.BaseDirectory,     ConfigurationManager.AppSettings['luceneIndex'].TrimStart('\\')); 

This will look in the caller’s app.config for an appkey called ‘path’ and combine its value to the caller’s path. The TrimStart() makes sure that the config file can both contain a leading \ or not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:50:32+00:00Added an answer on May 11, 2026 at 6:50 am

    Since you are referencing this from a separate library, you might have to jump through a bunch of hoops to get access to the HttpServerUtitity or introduce some coupling to classes that are difficult to mock. You might want to consider having a single configuration class that loads properties from the web configuration that gets injected into your library via constructor/setter. To make it easier to test against, you could define an interface that could be mocked in your unit tests and have it implement that. The configuration class could use the HttpServerUtility to obtain the absolute path and store it internally to be reused.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Asp.net MVC project that modestly uses jQuery scripts. My views also
I have this ASP.net MVC project that requires a wizard like interface... So I
I have an ASP.NET MVC project and I have a single action that accepts
I have an ASP.NET MVC project with a form. In the Action method that
The default ASP.NET MVC project sets up a Models directory that I don't know
I have an ASP.NET MVC 2 project that renders conventional strongly typed pages, but
I have a ASP.NET MVC project that has a static class in it to
I currently have a POCO class in my ASP.NET MVC project that handles all
I have a 3 tier ASP.NET MVC 3 project that has a data layer,
I have an asp.net MVC project where i need to define some custom routes.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.