首页 > 解决方案 > 角度访问 IIS 中的虚拟目录,端口为 4200

问题描述

我已经配置了一个包含一些照片的 IIS 虚拟目录,但是我可以从 Angular 应用程序访问 trublle。我有一个 404 NOT FOUND 错误。同时,我可以通过 80 端口的链接访问该文件夹。

我试图在 IIS 上绑定时添加端口 4200,但在这种情况下应用程序将无法工作

我已经添加了这个代码启动但即使删除它也没有影响:

public override void AddApplicationSpecificConfigure(IApplicationBuilder app, IHostingEnvironment env)
    {

        app.UseFileServer(new FileServerOptions
        {

            FileProvider = new PhysicalFileProvider(
                           Path.Combine(Directory.GetCurrentDirectory(), "UploadedImages")),
            RequestPath = "/StaticFiles",
            EnableDirectoryBrowsing = true
        });

这就是我收到图像链接的方式: 收到的网址

HTML 调用:

  <ng-container matColumnDef="url">
   <th mat-header-cell *matHeaderCellDef> Image Url </th>
   <td mat-cell *matCellDef="let element"> <img [src]="element.url" /> </td>
 </ng-container>

我可以从此链接访问照片:链接作品

这是错误: 错误

80 端口上的 IIS 绑定在此处输入图像描述

标签: angulariisvirtual-directory

解决方案


您可能在 80 端口上运行的默认网站中创建了虚拟目录。在 IIS 管理器中检查应用程序的端口绑定。

在此处输入图像描述


推荐阅读