Path To Files Inside Content Folder (ASP.NET MVC)

前端 未结 3 834
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 01:19

There something I still do not understand about how the Content folder works in ASP.NET MVC. To make things clearer I have a few questions:

  1. Is the Content folder t
3条回答
  •  鱼传尺愫
    2021-02-04 01:30

    1.Is the Content folder the root folder? I mean does http://localhost/ point to Content or is it something else?

    No, http://localhost:port/ does not point to content folder. You can access files in content folder through http://localhost:port/content/...

    2.I have a file named dummyIcon.png inside Content/images/temp folder. How do I locate it from my domain layer (which is a Code Library project)?

    You should be able to access it as http://localhost:port/Content/images/temp/dummyIcon.png

    3.What is the best practice of displaying images in ASP.NET MVC? Should I store a path to the image in the database (which I personally prefer), or do I save a byte array and return it to the view?

    Where you store the images depends on your application needs. Are these generic images that is used to display application images (icons, company logo, etc).. Then it is best to store them in file system.

    If your application deals with images and you work on storing images, manipulation etc, then you may need DB. I think, storing images used on the web application is a overhead.

提交回复
热议问题