Hello,
I am trying to connect asp.net from android client. Do you guys have any tutorials on this topic?
How to connect ANDROID Client to ASP.NET
I am trying to develop a simple chat application using Visual Studio and signalr. I have started as below and it works fine on a local server.
Then I uploaded it on hosting website and signalr connects on desktop such as: Chrome, Edge and Internet Explorer.
The challenge becomes when I try to open the app on smart phone. I have Samsung phone, which uses Android. When I ran the app on my phone it gives me ‘UNDEFIND’ error message. I searched a lot on google for solution but no luck.
Could you help me why the code below is not connecting signalr on smart phone please?
Please try the code below on hosting server using mobile phone.
Startup class
[assembly: OwinStartup(typeof(ChatTest_WebApp.App_Start.Startup))]
namespace ChatTest_WebApp.App_Start
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
<script src="../Scripts/jquery-3.5.1.min.js"></script>
<script src="../Scripts/jquery.signalR-2.4.1.min.js"></script>
<script src="../signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var chatHub = $.connection.chatHub;
alert(chatHub);
$.connection.hub.logging = true;
$.connection.hub.start().done(function () {
registerEvents(chatHub);
});
});
function registerEvents(chatHub) {
$("#btnStartChat").click(function () {
var name = $("#txtNickName").val();
var email = $('#txtEmailId').val();
if (name.length > 0 && email.length > 0) {
chatHub.server.connect(name, email);
$(location).attr('href', '~/Message.aspx');
}
});
$("#txtNickName").keypress(function (e) {
if (e.which === 13) {
$("#btnStartChat").click();
}
});
}
</script>
<input id="txtNickName" type="text" class="textBox" />
<input id="txtEmailId" type="text" class="textBox" />
<input id="btnStartChat" type="button" class="submitButton" value="Sign" />