简体   繁体   中英

How to have an asp.net mvc app receive simple text string data from a client?

I am implementing an ASP.NET MVC 5 application that needs to receive data from a client, but I am uncertain how to do this.

The client is a GPS tracking unit that delivers a longitude and a latitude every 10 sec. The data is a comma separated text string so only very small amounts of data, the whole string is around 40 characters long.

Once I have the data I will display the longitude and latitude as simple text in my application. The data should only be displayed realtime and not saved/stored in any db or anything. I can configure the client to connect through GPRS to whatever IP:Port address I want.

I have implemented a simple server using Winform which runs on my local machine using TcpListener and StreamReader . I can get the client to connect to this one, and can get the data no problem. But not sure how to make this in my asp.net application. Should I implement TcpListener in my viewmodel? I suspect that this is not the right way to do it.

It should just be as simple a solution as possible.

Any help or links to examples will be much appreciated.

Best regards Kasper

You can use SignalR .SignalR is a new developer's API provided for ASP.NET web applications, used to add "real time" web functionality to ASP.NET applications.

Check out following link for more information

Tutorial: Getting Started with SignalR 2 and MVC 5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM