I have been entangled in this problem for several days. Although I haven't fully understood it, I just made some progress. I will record it. If you have any detailed answers, please don't hesitate to give me some advice.
Opening part:Those familiar with MVC understand that the controller and the action in it will correspond to the files in views by default, so that the content in the Controller will be transmitted to the page and displayed on the browser. For example, it is the structure of the default views in the original mvc3 project.
If we want to create another set of page themes and implement a free switch with the built-in style above, we simply need to follow the directory structure below views and then perform a parallel set with it. The directory structure is as follows:
We added the themes file under views, which is divided into default and green. The default file is the original file, and the Green file is another set of style Files written by ourselves.
Next, we will use the razorviewengine class written in the title of this article. inherit from the razorviewengine class and use the custom engine to switch between the default and green themes. (Find the specific operation in the garden. I have written many articles. I am not so embarrassed. The following mainly describes my own problems)
Problem:In default and green, I put content to write CSS files and JS files. Because the two themes are different, separate calls here is also the most intuitive solution. However, the problem occurs. The custom view engine can smoothly switch between default and green to load the account, home, and shared folders, however, when the Page Link label in the content folder loads the style, 404 appears.
In the debugging window of chrome F12, the status after the file in the request content is canceled.
I found a lot of information that I was still not satisfied with. One answer was that the reason for Cross-site access was always confused.
However, after many attempts, I finally found that the content folder is not in the correct position! You just need to take it out and call it smoothly.
Finally, I put the conent under the project root directory, and set up default and green respectively to differentiate different style files. In this way, the freely switching feature of the topic can be completed.
The function is complete, but Why cannot the content be stored in views managed by the view engine *_*