【发布时间】:2016-11-07 15:47:33
【问题描述】:
我一直在学习 Angular2。在 nodejs lite-server 上运行时,路由工作得很好。我可以转到主 (localhost:3000) 页面并浏览应用程序。我也可以输入 localhost:3000/employee ,它会转到请求的页面。
该应用最终将运行在 Windows IIS 7.5 服务器上。如果我从主页 (localhost:2500) 开始,路由工作正常,我可以毫无问题地通过应用程序。我遇到问题的地方是尝试直接转到主登录页面(localhost:2500/employee)以外的页面。我收到 HTTP 错误 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 知道路由。
【问题讨论】:
-
你用的是什么asp.net框架? MVC? .net 核心?
-
不使用 asp.net 框架。仅限 Angular2。其中包括 HTML、CSS 和 Javascript。
-
你解决了吗?
-
您介意接受我对此的回答吗? -贾德森