Is It possible to create HTML5 Web Socket by use of ASP.NET/Web Form?
-
I like to use Asp.net with Web form. I have been advice not to use Web forms. what is the reason?Sam Jelveh– Sam Jelveh2012-06-23 18:15:21 +00:00Commented Jun 23, 2012 at 18:15
-
There plenty of reasons to pick either, so best thing is to ask for reasons from whoever give you an advice.Alexei Levenkov– Alexei Levenkov2012-06-23 18:21:26 +00:00Commented Jun 23, 2012 at 18:21
-
Please clarify your question what you want to do: communicate with a web socket server from browser, from server or you want to implement your own.Alexei Levenkov– Alexei Levenkov2012-06-23 18:22:46 +00:00Commented Jun 23, 2012 at 18:22
-
ASP.NET comes in two flavors: WebForms and MVC. Both allow you to create webapplications with the .NET framework. ASP.NET WebForms does its best to pretend you are in a stateful environment where you are anything but. ASP.NET MVC offers a project architecture based on the Model-View-Controller pattern. Which is right for you, is a matter a preference. I'm a big MVC fan myself and the person who adviced you not to use WebForms probably is as well.J.P.– J.P.2012-06-23 18:23:04 +00:00Commented Jun 23, 2012 at 18:23
-
Thanks for info, if I choose web form is it possible to use code behind in order to create such a programme? or is it only possible to create a separate class to implement my game logic?Sam Jelveh– Sam Jelveh2012-06-23 18:27:14 +00:00Commented Jun 23, 2012 at 18:27
3 Answers
Uhm. No. HTML5 web sockets are a client-side feature, meaning you can use it with JavaScript code through the WebSocket object. Thus, from the client-side code you write in your ASP.NET WebForms/MVC project, you are able to use it.
If you are trying to support the web socket protocol through ASP.NET, that is possible with a very new version of ASP.NET. Is this what you're trying to do? Your question is a bit vague.
3 Comments
The short answer is No, not with .NET 4.0 and IIS 7.5 (current production releases of .NET and IIS respectively). As J.P. mentions there will be support for web sockets in the future. More specifically, IIS 8 will be able to support this along with some additions to the System.Net namespace that will be bundled with ASP.NET 4.5.
In the mean time you may be interested interested in learning a bit more about SignalR. It includes a client side library that makes use of HTML5 Web Sockets, but falls back to long-polling if web sockets aren't supported by either the client or the server. And best of all, this fallback mechanism is transparent to the client and implementer. A .NET server implementation that supports web sockets is also provided.
This SO Q & A may also be of interest.
2 Comments
You should consider trying VisualJS.NET . Which is builtin reverse ajax and websocket supported asp.net web application development layer.