Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ASP.Net MVC & node.js together

I am writing a ASP.Net MVC app that connects to a SQL database and uses existing C# libraries I have.

I also have a TCP server Windows application that sends/receives TCP messages via XML. I have successfully setup node.js and socket.io to handle all this and have a html page that sends/receives messages to the server. Node.js is serving up the html page at the moment. The XML is converted to JSON when sending/receiving data.

I am planning on setting my MVC app to serve the page up but was just wondering what your thoughts are on this use of cross framework setup. Does it seem viable and a good solution for handling TCP messages and sending it to the browser? I have also read about iisnode for hosting node in IIS which I guess would be a good idea for my setup. What are your thoughts on this?

like image 827
Jon Avatar asked Sep 21 '11 08:09

Jon


People also ask

What is ASP.NET MVC used for?

Based on ASP.NET, ASP.NET MVC allows software developers to build a web application as a composition of three roles: Model, View and Controller. The MVC model defines web applications with 3 logic layers: Model (business layer) View (display layer)

Is ASP.NET MVC still used?

Note that the entire ASP.NET MVC library is now obsolete.

Is ASP.NET MVC easy to learn?

It's really difficult to try and learn an entirely new language/framework under pressure. If you're required to deliver working software for your day job, trying to learn ASP.NET Core at the same time might be heaping too much pressure on yourself.

What is MVC in .NET with example?

The MVC convention is to put controllers in the Controllers folder that Visual Studio created when the project was set up. Let's take a look at a simple example of Controller by creating a new ASP.Net MVC project. Step 1 − Open the Visual Studio and click on File → New → Project menu option.


1 Answers

You basically have two websites. One is your ASP.NET MVC website. and the other is a web client for your TCP windows application.

Since they are disjoint it will work fine.

You may want to have that web client's html server through ASP.NET MVC and only run a websocket server on node.js though. You may need to do some proxying to get the same origin to work.

If you server your HTML page from a webserver running IP Y, port X and then try to talk to the node.js websocket server running on IP Y, port X + n it may violate the same origin restriction.

This means your basically loading a socket.io client from server A and trying to talk to server B. The web page doesn't know you own both of these servers.

The solution would be a proxy, you proxy all requests to server A and B but since they all go through the proxy it doesnt violate the same origin.

As for proxy, nginx is one. There is a node-proxy. And IIS might be able to proxy it for you (Although I doubt IIS makes a good proxy)

like image 186
Raynos Avatar answered Oct 05 '22 02:10

Raynos