由于我已经使用ng build --deploy-url=~/LogisticAppUI/dist/
,然后从dist复制Index.html的代码并将其粘贴到 Index.cshtml,下面是Index.cshtml的代码。@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Color Admin</title>
<base href="/">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<meta content="" name="description" />
<meta content="" name="author" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body detect-scroll (onScroll)="handleScroll($event)">
<app>
<!-- begin #page-loader -->
<div id="page-loader" class="fade show"><span class="spinner"></span></div>
<!-- end #page-loader -->
</app>
<script src="~/LogisticAppUI/dist/runtime.js" defer></script>
<script src="~/LogisticAppUI/dist/polyfills-es5.js" nomodule defer></script>
<script src="~/LogisticAppUI/dist/polyfills.js" defer></script>
<script src="~/LogisticAppUI/dist/styles.js" defer></script>
<script src="~/LogisticAppUI/dist/vendor.js" defer></script>
<script src="~/LogisticAppUI/dist/main.js" defer></script>
</body>
</html>
现在该页面正常工作,它可以按要求登录,这是我单击Staff Members
Url,它将显示给我。据我所知,它正在尝试通过Controller名称进行访问,但在[[API中并不存在,如果我尝试点击URL],我只想在Angular内部访问它。 >而不是在WebApi中搜索它,它仅在我用于POST]和GET时才有效,而在下面这样正确地工作。] > Visual Studio 2019 with API]集成在一起时,当开始使用Controller名称时点击UrlStaffInfoAdd(_Staff: Staff,ProfilePicFile: File) {
const fData = new FormData();
fData.append('Id', _Staff.Id == null ? '' : _Staff.Id.toString());
fData.append('FirstName', _Staff.FirstName);
fData.append('SendEmail', _Staff.SendEmail.toString());
fData.append('SendPhone', _Staff.SendPhone.toString());
fData.append('Password', _Staff.Password);
if(ProfilePicFile != null){
fData.append('FileUpload', ProfilePicFile, ProfilePicFile.name);
}
const hdrs = new HttpHeaders().append('Content-Disposition', 'mulipart/form-data');
this.http.post(HostedPathConst.HostedPath + `Staff/Register`, fData, {headers:hdrs})
.subscribe(this.Success, this.Error);
this.messageStaffSource.next(_Staff);
}
GetStaff(): Promise<any> {
const promise = this.http.get(HostedPathConst.HostedPath + `Staff/GetStaff`).toPromise();
return promise;
}
当我在Visual Studio Code中独立地用于Angular 8时,但当我将其与
正如我在使用ng build --deploy-url =〜/ LogisticAppUI / dist /之后将其集成到HomeController的Index.cshtml中,然后从dist复制Index.html的代码并将其粘贴到Index.cshtml中,... useHash: true
。它应该看起来像下面的代码。@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }