(1)SignalRServer:C# project, user persistence connection's SignalRServer. The SignalRServer is the bridge bewteeen Window Form and WebForm.
(2)SignalRClientWinForm:SignalR Client,Window Form Project with C#, first input the user name and then click login button(send to SignalRServer and insert a user info to User List), and then input the word you want to say and click send button. The SignalRServer
will broadcast to all user.
(3)SignalRClientWebForm:SignalR Client,ASP.NET Web Form with C#, first input the user name and then click login button(send to SignalRServer and insert a user info to User List), and then input the word you want to say and click send button. The SignalRServer
will broadcast to all user.
The connection of Window Form and SignalRServer has no problem. They can communicate each other. The connection of Web Form and SignalRServer also has no problem on IE11. But if I use Google Chrome(version 58.0.3029.110 (64-bit)) to run the Web Form, the
connection from Web Form(Javascript) to SignalRServer will be fail.
I Show my JavaScript of Web Form Client as below. I think the problem is at connection.start(), but I am not sure that whether add the OnError function (like) can get the error message in the connection.start?
Does somebody know how to solve this problem? Because my projects in this solution use .net framework 4.0 and then want to integrate with other .net framework project. So I cannot upgrade to .net framework 4.5.
<script type="text/javascript">
var bUseLocal = true;
var ConnectionID = "";
$(function () {
if (bUseLocal) {
connection = $.connection("http://localhost:20926/realtime/echo");
}
else {
connection = $.connection("http://192.168.1.1/SignalRServer/realtime/echo");
}
connection.logging = true;
connection.received(function (data) {
var messageBase = data;
if (messageBase.CommandName == "RequestInfo") {
ConnectionID = messageBase.ConnectionID;
}
else if (messageBase.CommandName == "TalkWord") {
var TextAll = document.getElementById('TextAll');
TextAll.value += messageBase.Word + "\r\n";
}
});
connection.start().done(function () {
alert("connection success");
$("#ButtonLogin").click(function () {
var TextUserName = document.getElementById('TextUserName');
var LoginData =
{
CommandName: 'LoginData',
ConnectionID: ConnectionID,
UserName: TextUserName.value
};
var str = JSON.stringify(LoginData);
alert(str);
connection.send(str);
});
$("#ButtonSend").click(function () {
var TextUserName = document.getElementById('TextUserName');
var TextSend = document.getElementById('TextSend');
var word = TextUserName.value + ":" + TextSend.value;
var TalkWord =
{
CommandName: 'TalkWord',
Word: word
};
var str = JSON.stringify(TalkWord);
connection.send(str);
});
});
});
</script>
Member
16 Points
77 Posts
ASP.NET WebForm(C#) with SignalR only can run on IE11, use Google Chrome cannot connection sucees...
May 26, 2017 01:55 AM|akira32|LINK
Complete Source Code:https://onedrive.live.com/embed?cid=FBEB6373D9321A7F&resid=FBEB6373D9321A7F%21691613&authkey=AFmObvYCI95xn2I
This solution is consist of three projects:
(1)SignalRServer:C# project, user persistence connection's SignalRServer. The SignalRServer is the bridge bewteeen Window Form and WebForm.
(2)SignalRClientWinForm:SignalR Client,Window Form Project with C#, first input the user name and then click login button(send to SignalRServer and insert a user info to User List), and then input the word you want to say and click send button. The SignalRServer will broadcast to all user.
(3)SignalRClientWebForm:SignalR Client,ASP.NET Web Form with C#, first input the user name and then click login button(send to SignalRServer and insert a user info to User List), and then input the word you want to say and click send button. The SignalRServer will broadcast to all user.
The connection of Window Form and SignalRServer has no problem. They can communicate each other. The connection of Web Form and SignalRServer also has no problem on IE11. But if I use Google Chrome(version 58.0.3029.110 (64-bit)) to run the Web Form, the connection from Web Form(Javascript) to SignalRServer will be fail.
I Show my JavaScript of Web Form Client as below. I think the problem is at connection.start(), but I am not sure that whether add the OnError function (like) can get the error message in the connection.start?
Does somebody know how to solve this problem? Because my projects in this solution use .net framework 4.0 and then want to integrate with other .net framework project. So I cannot upgrade to .net framework 4.5.
Member
520 Points
286 Posts
Re: ASP.NET WebForm(C#) with SignalR only can run on IE11, use Google Chrome cannot connection su...
May 29, 2017 02:14 AM|EvenMa|LINK
Hi akira32,
I reproduced your project and I found the issue was occurred by cross-domain.
You could enable cross-domain such like the following code on SignlaR server, then it works well on chrome.
If you have any other questions, please feel free to contact me any time.
Best Regards
Even
Member
16 Points
77 Posts
Re: ASP.NET WebForm(C#) with SignalR only can run on IE11, use Google Chrome cannot connection su...
May 30, 2017 04:59 AM|akira32|LINK
Thank you,EvenMa. I had solved this problem. Thanks!