(5) Net Core uses static files

1. Introduction


1. Net Core cannot access static files by default. You need to add definitions in Startup through code.

2. This article introduces two static file directory implementation methods.

 

Second, enable the default directory


1. Add image files

2. Test access results (cannot access)

3. Add the definition code.

4. Refresh the picture to view the results (normal access).

Here is a knowledge point. I usually use browsing mode to access instead of F5 to run. The advantage is that the code can be modified. After Net Core modifies the code, the refresh access will automatically recompile.

  

 

 

 

 

 

3. Enable custom directory


1. Add a custom directory code (the code is self-interpreted and understood )

2. Refresh the above picture access. (Using the above knowledge points to understand this operation)

3. View the running directory (the folder has been automatically generated)

4. Add a file to the directory.

5. View the added files. (normal access)

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325254000&siteId=291194637