admin管理员组文章数量:1391977
I have an ASP.NET (.NET 4.7) application and I want to load a static file that's included in my project.
The problem is the project is a child of the main web project. I can't find a way of actually finding the right path. The file is marked as content and copy to output directory and I can see it in the bin folder of the parent project.
This child project doesn't reference any MVC stuff so I don't have access to HttpContext
.
My failed attempts so far:
Assembly.GetExecutingAssembly().Location
- returnsTemp
folder that only contains dll / pdb files for my child project (and a random .ini file)AppDomain.CurrentDomain.BaseDirectory
- returns the root of the parent project's folder (not the bin, but the location of the.csproj
)Environment.CurrentDirectory
- returns the IIS Express folder- The path
"."
references the IIS Express folder
This seems such a basic thing - I must be missing something obvious!
本文标签: cHow can I load a content file from a child project in an ASPNET applicationStack Overflow
版权声明:本文标题:c# - How can I load a content file from a child project in an ASP.NET application - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744742473a2622690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论