从 mvc 视图重定向到 angular 路由 - Angular 6

Redirect from mvc view to angular route - Angular 6

我已将 angular 项目与 ASP.NET MVC 集成。我想在第一次加载时将我的 MVC 页面重定向到 angular 路由。我的 Index.cshtml 页面

中有以下代码
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Myapp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body class="skin-blue sidebar-mini wysihtml5-supported">
<app-root></app-root>
<script type="text/javascript" src="~/Scripts/client/runtime.js"></script>
<script type="text/javascript" src="~/Scripts/client/polyfills.js"></script>
<script type="text/javascript" src="~/Scripts/client/styles.js"></script>
<script type="text/javascript" src="~/Scripts/client/vendor.js"></script>
<script type="text/javascript" src="~/Scripts/client/main.js"></script>
</body>
</html>

我在 angular 索引页中也有 index.html 页面配置。

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Myapp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>
<div class="wrapper">
</div>
</app-root>
</body>
</html>

现在我需要将页面从此处重定向到 angular 路由,其中​​为 angular 定义了登录路由。

{ path: 'login', component: LoginComponent },

您的 cshtml 文件已具备 Angular 到 运行 所需的一切。不需要 index.html 文件。

尝试将其添加到您的路由配置中。

{path:'', redirectTo:'login', pathMatch: 'full' }

一旦你添加这个 Angular 应该默认重定向到登录路由。