2

In ASP.NET Core MVC these ways are possible to serve Favicon:

  1. Place favicon in wwwroot and then serve it using /favicon path

  2. Place it in a custom folder, and then use PhysicalFileProvider to configure delivering static files with special patterns from that folder

However, the third way, which by the way is the old way, is to put Favicon in the root folder of the project, and serve it from there.

I need the third option because we're using a Software Production Line, that has its rules.

So, is it possible?

Update: Some point me to the old questions regarding ASP.NET MVC. For those people, ASP.NET Core MVC serves static contents differently and these two technologies are not the same. Anything static in ASP.NET MVC would be served as simple as pointing to it in URL. In ASP.NET Core MVC things are different.

9
  • 3
    @GSerg, what does UseStaticFiles have to do with the post you linked to? IgnoreRoute doesn't exist in ASP.NET Core, so that doesn't apply. He's asking about the project folder, not the site folder, which is what you get with UseStaticFiles. Commented Feb 25, 2018 at 11:34
  • 1
    Yeah it does look like a dupe of that second one. Although I'd use Directory.GetCurrentDirectory instead of a hard-coded path like that answer suggests. Commented Feb 25, 2018 at 11:52
  • 1
    No, this is not the duplicate of the second mention question. That question refers to outside of the site folder, or wwwroot folder, which turns out to be yet another folder. My question is very specific about the root of project, just sibling to Program.cs and Startup.cs. Commented Feb 25, 2018 at 11:58
  • 2
    Your code does not run from your project folder. It runs from a server where it is deployed, and your project structure is not there anymore. If you place favicon.ico in the root folder of the project, it will be ignored by default. If you set its Copy to Output Directory to Copy Always, it will be copied into the root folder of the deployed website, just outside the wwwroot folder. You can then use the StaticFileOptions and target that location with Directory.GetCurrentDirectory like @McGuire suggests. Commented Feb 25, 2018 at 12:21
  • 1
    "I need the third option because we're using a Software Production Line, that has its rules." - What are the rules? Commented Feb 26, 2018 at 0:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.