Background: I have a ASP.NET MVC3 app, with a database. I also have a complex console app, which (amongst other things) initialises the web app's database: generate, add constraints, add sprocs, add triggers, seed, etc. I cannot move the console logic into the web app (doesn't make sense in our architecture).
Problem:
The console app is obviously not running in a hosted environment, so does not have access to HostingEnvironment
, MapPath
, HttpContext.Current
, Server.MapPath
, ~
, etc. But I need access to the web app's paths from the console app. Also, the console app calls into the web app, which then uses these classes normally, but which are of course all null or undefined.
Question: Is there some way to spoof one of these classes so that I can access the hosting environment's path mechanism, even though it's not running?
I can hardcode all the paths I need into the console app, but that is highly undesirable.
I'm under the impression that this should be possible, because the same need would be required for unit testing.
TIA