How can an OWIN startup method get the base URL of the web site?
I\'m trying to write code that will work when debugging with IISExpress, unit testing with self hosting
For anyone under vNext, try this:
public void Configure(IApplicationBuilder app)
{
app.Use(async (ctx, next) =>
{
var hostingEnvironment = app.ApplicationServices.GetService();
var realPath = hostingEnvironment.WebRootPath + ctx.Request.Path.Value;
// do something with the file
await next();
});
}
If you're not under vnext, I did see this answer that did not work for me under vNext / dnx: https://stackoverflow.com/a/24747658/486028
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
Under dnx this just game me the folder containing the .dnx runtime but might work under other contexts