In the .NET CORE
application, I'm using static files in wwwroot
folder.
while running it as dotnet run
the index.html
file is displayed smoothly and normal at localhost:port/
but after publishing the app as SCD
self-contained development package, and run the .exe
generated file, the static files
are not displayed at the localhost:port/
.
In the developer screen of the browser, I got 404 error
that is file not found.
Add the corresponding statement in your
project.json
:Apparently the files other than
.cs
as not packaged, and needed to be added manually to thepublish
folder.I've the below example for sending html file as attached email:
and the files structures are:
project.json
program.cs
The above worked very fine, and the
publish
had been prepared running the below commands:but while executing the
.exe
file in thepublish
folder, it gave an error that the filepathTo/html-files/msg.html
is not found.Once I copied the folder required to the
publish
folder as below, everything worked fine:NOTE If you do not need the public/static file to be seen by the user, then you can compress them, then read them from memory stream, as explained here