相关疑难解决方法(0)

如何从 Xamarin 客户端连接到 SignalR 服务器?

(**) 我创建了一个 ASP.NET Web 服务器,托管 SignalR 集线器。我跟着这个 教程。有用。然后我创建了一个 Xamarin.Android 客户端(*)。问题是我无法连接到服务器。我想,由于主机地址中的“localhost”,我无法连接。例外是相当大的。

如果我的怀疑是正确的,我该如何解决?如何使本地主机看起来像普通服务器?

(*) - 我也尝试过使用 Xamarin.Forms。

(**) - 请看问题底部的“编辑”。

这是我的方法:

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        // Get our button from the layout resource,
        // and attach an event to it
        Button button = FindViewById<Button>(Resource.Id.MyButton);

        button.Click += async delegate 
        {
            button.Text = string.Format("{0} clicks!", count++);
            var hubConnection = new HubConnection("http://localhost:64642");
            var chatHubProxy = hubConnection.CreateHubProxy("ChatHub");
            try
            {
                // Start the …
Run Code Online (Sandbox Code Playgroud)

c# asp.net xamarin.android signalr xamarin

2
推荐指数
1
解决办法
3570
查看次数

标签 统计

asp.net ×1

c# ×1

signalr ×1

xamarin ×1

xamarin.android ×1