How to access files within the wwwroot folder of a different project? c# html html-agility-pack


I have 2 projects that are needing to talk to one another. The first is a ASP.NET MVC project, that when in production, has a feature where the user can edit an html template that is stored in the wwwroot folder of the project.

The second project is a C# console app that grabs some user data from a database, and then uses that data to email surveys to users. The html template from the first project is needing to be grabbed by this console app so that it can be used in sending out these emails. I was hoping to use HtmlAgilityPack to grab the html email template from the first project when it is live, something along the lines of this:

var web = new HtmlWeb();
var document = web.Load("");
string text = document.ParsedText;

But I'm open to other ideas that might work in this case. More or less I think I just need to figure out how to access static html files from within the wwwroot folder from a browser path, if that's possible. Oh and these two projects are going to be running on different servers, so local paths won't work. Thank you!

1/12/2018 10:44:27 PM

Accepted Answer

In large part thanks to ADyson's comments, the course of action that makes most sense in this situation is to create a small API within the MVC app, that fetches the html file, and the console app will call this API to retrieve the needed html.

1/16/2018 12:34:23 AM

Popular Answer

I had a similar problem, and I did it by adding ~/ in the beginning of my static file addresses in my _Layout.cshtml. My template files and photos were no longer loaded in the project but the layout was loaded. This way the files were also loaded

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow