Home > Net >  All href in html produces 404 error when using APS.NET MVC
All href in html produces 404 error when using APS.NET MVC

Time:10-28

I just migrated all my html code to APS.NET Core, but all links to other pages failed and give 404 error, for instance this bookmark links to the file Companies.cshtml which is in the same View/Home folder.

<div>
     <a href="Companies.cshtml#google-i">foo</a>
</div>

I tried to add folders to the workspace with browser inspection but no avail. I also tried add ~/ to the path, does not work. I've noticed that the localhost cannot find the file Companies.cshtml in a virtual file system(?) and thus may be the reason that produces the error. How may I bypass the issue?

CodePudding user response:

You cannot link to a view. You need an action that loads that view, and then you link to the route that directs to that action.Read enter image description here

  • Related