0

Is It possible to create HTML5 Web Socket by use of ASP.NET/Web Form?

6
  • 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, 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. 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. 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.
    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
    Jun 23, 2012 at 18:27

3 Answers 3

2

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
  • 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, 2012 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: stackoverflow.com/questions/2082613/…
    – J.P.
    Jun 23, 2012 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, 2012 at 20:53
2

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.

.NET 4.5 WebSockets vs SignalR

2
  • 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, 2012 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, 2012 at 22:11
0

You should consider trying VisualJS.NET . Which is builtin reverse ajax and websocket supported asp.net web application development layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.