Running a copy of a .cshtml file gives a 404

前端 未结 1 1590
臣服心动
臣服心动 2021-01-28 06:25

I\'ve created a copy(right-click Copy & Paste) of my Home page in a VS2013 ASP.NET MVC5 project and named it indexL10. When I try to run it, I get the following error:

相关标签:
1条回答
  • 2021-01-28 07:21

    *.cshtml files are not like *.aspx files. They're not directly exposed. The URL is translated by the framework into a route. That route points to a particular controller and a particular action in that controller, which is then called by the framework. The action returns an ActionResult, which in MVC is most typically satisfied via a ViewResult. Conventions in the framework come into play to look for a view to render with the same name as the action that was called, but this is not strictly required and can be overridden. Regardless, the view (your *.cshtml file) is rendered by Razor utilizing data provided by the action and returned as a response to the client.

    0 讨论(0)
提交回复
热议问题