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 Jun 23 '12 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 Jun 23 '12 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 Jun 23 '12 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. Jun 23 '12 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 Jun 23 '12 at 18:27
-
ASP.NET WebForms offers .aspx files for defining the user interface and associated .aspx.cs files ("code behind files") where you can implement user interface logic. If you want, you can place your game logic here, however in most cases it is wiser to place this in a seperate class. – J.P. Jun 23 '12 at 18:37
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.

- 5,567
- 3
- 25
- 39
-
I am trying to create a game with Web Socket (download the super Web Socket open source from codeplex.com). I have already created the game on web Service with Web form but not sure is it possible to created on Web form with use of Web socket? – Sam Jelveh Jun 23 '12 at 18:22
-
If I understand you correctly, you have created webservices within an ASP.NET WebForms project and you want to make these webservices work with HTML5 web sockets. If your webservices were created with WCF, this question should help you: http://stackoverflow.com/questions/2082613/is-there-a-wcf-server-implementation-of-web-sockets-form-html-5 – J.P. Jun 23 '12 at 18:34
-
thanks you. 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 Jun 23 '12 at 20:53
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.

- 1
- 1

- 1,766
- 18
- 31
-
thanks, I am wondering is it possible to use code behind to implement the game logic in order to create the Web Socket game or is it better to use separate class for game logic? – Sam Jelveh Jun 23 '12 at 22:07
-
I have to added here, I have already created my application on web socket with ASP.net 4.0 it was possible. I just wondering is it possible to use code behind to implement the game logic in order to create the Web Socket game or not? – Sam Jelveh Jun 23 '12 at 22:11
You should consider trying VisualJS.NET . Which is builtin reverse ajax and websocket supported asp.net web application development layer.

- 1,495
- 11
- 18