【问题标题】:Net Core WebApi 2.1 and Angular 2 app - IIS DeploymentNet Core WebApi 2.1 和 Angular 2 应用程序 - IIS 部署
【发布时间】:2020-06-12 03:41:51
【问题描述】:

WebApi (outofprocess) [VS2017: Publish] 和 Angular [build --prod] 托管在 IIS 的同一端口:IIS 10 上的 80 上。Angular 在 api 文件夹中构建 wwwroot 和 webapi,ApplicationPool 具有 IUSR 访问托管文件夹的权限. index.html 加载正确。

但以下 uri:http://website.com/applicationusers/authenticate [两个参数:用户名和密码]返回以下错误:“错误类型错误:您在预期流的位置提供了 'undefined'。您可以提供 Observable、Promise、Array 或可迭代。”

我注意到 IIS 没有启动/加载 dotnet.exe,因为我在任务管理器中没有看到它。

但是当我在命令提示符下运行 dotnet.exe website.dll 时,api 会在 localhost:5000 加载,当我在邮递员中使用以下命令对其进行测试时:http://localhost:5000/api/applicationusers/authenticate 我得到了响应。

我是否遗漏了导致 IIS 问题的东西...感谢任何想法...

【问题讨论】:

    标签: angular asp.net-core-2.1


    【解决方案1】:

    当您尝试从 Angular 应用程序调用 REST 端点进行身份验证时,似乎会生成此错误。尝试在从 Angular 应用程序调用 REST 端点时添加 Promise 或 Observable。

    【讨论】:

    • 我试过了,但我没有做对。以下是我的方法: login(username: string, password: string) { return this.http.post(${environment.apiUrl}/applicationusers/authenticate, { username: username, password: password }) .pipe(map(user => { if (user && user.token) { localStorage.setItem('currentUser', JSON.stringify(user)); return user; } }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 2018-04-11
    • 2021-05-08
    • 2018-02-16
    相关资源
    最近更新 更多