'ASP.NET core - How to href to an html/cshtml page from a button inside another html/cshtml
I need to access an html page "Pages/createCampaign.html" and/or "Pages/addCampaign.cshtml" and/or "wwwroot/html/insertCampaign.html" (I've created more as tests, but none seems to be working) from a click on a button inside "Pages/Index.cshtml".
Inside html.cshtml:
<button type="button" class="create_but">
<a href="../Pages/createCampaign.html">
Create Campaign
</a>
Follows the tree:
Inside I've tried href="../Pages/createCampaign.html", href="../Pages/addCampaign.cshtml", href="../wwwroot/html/insertCampaign.html", and way more using tilde and more options.
The only one I can access from Index.cshtml is the one in wwwroot/html folder BUT from there it can't find wwwroot/js and wwwroot/css whereas it can finds ~/css and ~/js from Pages.
What I need to do is to open the page to insert/create/add a Campaign from clicking that button in Index, but of course from there I need it to be linked to my css and js files.
How could I solve this situation?
Solution 1:[1]
I've read everything I found about static files and web root. Without specifying the file type from Index.cshtml I'm able to find addCampaign.cshtml like this:
<a href="~/addCampaign">
Create Campaign
</a>
And seems like it can access js and css by <script src="~/js/site.js"></script> <link rel="stylesheet" type="text/css" href="~/css/site.css" media="screen"/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sara Briccoli |

