How do I fix my routing? I have a C# project with an Angular front-end. If I go to a c# View which calls an Angular component everything breaks. If I call an Angular view (directly from the URL) everything works fine.
C# routing to a c# view
- If I route properly in startup.cs I go to:
xxx/Home/indexwhich is simply a View that calls an Angular component (which throws a bunch of 500 errors)
Manually routing to Angular
- If I manually add
/anythingto the url (xxx/Home/Index/anything) the Angular routing takes over and everything loads fine.
Index method call
public class HomeController : Controller
{
public IActionResult Index()
{
return View("IndexAng");
}
}
IndexAng.cshtml
@{
ViewData["Title"] = "Home Page";
}
@*<script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>*@
@*<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>*@
<h3>Loading Ang App root:</h3>
<app-root></app-root>
<script src="~/dist/vendor.js" asp-append-version="true"></script>
@section scripts {
<script src="~/dist/main-client.js" asp-append-version="true"></script>
}
errors when calling the c# routing: 
from c# View calling Angular component breaks, but calling Angular directly works fine
No comments:
Post a Comment