我一直在学习Angular2。当在nodejs的lite-server上运行时,路由正常工作。我可以进入主页(localhost:3000),并在应用程序中移动。我也可以输入localhost:3000/employee,并且它将转到请求页面。
该应用程序最终将部署在Windows IIS 7.5服务器上。如果我从主页(localhost:2500)开始,路由就可以正常工作,我可以毫无问题地浏览整个应用程序。但是,当尝试直接进入除主要登陆页面以外的其他页面(例如 localhost:2500/employee)时,我会遇到 HTTP Error 404.0 错误。
这是我处理路由的 app.component 文件。
import { Component } from '@angular/core';
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated';
import { HTTP_PROVIDERS } from '@angular/http';
import { UserService } from './services/users/user.service';
import { LogonComponent } from './components/logon/logon.component';
import { EmployeeComponent } from './components/employee/employee.component';
@Component({
selector : 'opi-app',
templateUrl : 'app/app.component.html',
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS, UserService, HTTP_PROVIDERS]
})
@RouteConfig([
{
path: '/',
name: 'Logon',
component: LogonComponent,
useAsDefault: true
},
{
path: '/employee',
name: 'Employee',
component: EmployeeComponent
}
])
export class AppComponent { }
我想说我明白这个问题。IIS正在寻找/employee目录,但它不存在。我只是不知道如何让IIS意识到路由。