angular - 带有 .NET MVC 和 Angular 的动态服务器 baseUrl
问题描述
我正在用一个应用程序测试一些 SignalR,一切正常。现在要在服务器(azurewebsites)中对其进行测试,我需要将 baseUrl 设为动态并获取当前 url,以便可以建立 SignalR 集线器连接。
现在我有以下连接代码:
//server configuration
export let CONFIGURATION = {
baseUrls: {
server: 'http://localhost:51913'
},
}
SomeMethod()
{
this.connection = $.hubConnection(CONFIGURATION.baseUrls.server);
//... the rest of the process to connect to the hub.
}
显然,这不适用于 localhost 作为 URL。如何获取主机 url 以开始我的连接?有什么方法可以获取它或从例如 WebConfig 中读取它?我只是不知道热它有效。
PS:也许有一些可能在没有特定网址的情况下连接到我的集线器?
解决方案
只是如果以后有人有同样的问题:
我会将静态地址放入环境中,它会相应地改变
推荐阅读
- powershell - Powershell - 根据 ID 删除 TXT 中的重复行
- java - 将 Long 位运算转换为 BitSet 位运算
- html - IOS 15 Safari / 位置:固定和底部的地址栏
- c++ - 为八进制表示推广二进制左移而无需转换
- java - 如何在不本地创建 csv 文件的情况下将员工列表作为 csv 文件上传到 s3?
- laravel - [Route: BatterFirst.update] [URI: BatterFirst/{BatterFirst}] [Missing parameter: BatterFirst] 缺少必需的参数。编辑.blade.php)
- c++ - 通过增加频率对数组进行排序
- domain-driven-design - DDD 中的显式状态建模
- google-voice - 不使用浏览器从 Linux 登录 Gactions
- java - onDropdownRecyclerClick(int, java.lang.String) [不能应用于'(int)]