我有一个由运行在IIS上的Radzen IDE生成的Angular应用程序。应用程序中有一个锚标记,指向用于下载文件的.Net API。该锚点的href如下所示:
https://[AngularApp.mydomain.com]/api/ServerMethods/DownloadFile?fName=[NameOfTheFile.pdf]&ID=[SomeID]
当应用程序在http上运行并且我单击链接时,下载将按预期进行。当应用程序在https上运行时;无法匹配任何路由";错误:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL
Segment: 'api/ServerMethods/DownloadFile'
Error: Cannot match any routes. URL Segment:
'api/ServerMethods/DownloadFile'
当我使用Postman直接调用API时,即使使用https,下载也能工作。当我右键点击下载链接并点击"https"时,它也可以使用https;将链接另存为";。只有当我试图从Angular应用程序中打开链接,或者直接在浏览器中打开链接时,才会出现错误。
我需要在IIS中配置什么吗?我在应用程序池上尝试了.Net CLR版本或托管管道模式的不同设置,但没有效果。
您应该使用<a href="your/url"
而不是<a routerLink="your/url"
,因为在这里您在角度应用程序之外导航