Send data from console application to asp.net site

I am new to C # and .NET and I started working with a small local application.

In one visual studio solution, I have to create a website than receive messages written from a console application and display / store them in a database.

I was wondering if there is any "preferred" way to do this.

At the time, I came up with two possible ways to do this, I think.

First Method CA Console Application Links MVC Application WA Web Site which has a model class called Message. (this is just the message I want to convey)

When the user enters text into the command line and hits it, a new message is created with that text. From there I thought to use it <% ViewData["Variable"]%>

to transfer information. Is this a good way to do it?

Second method I haven't tested yet: My initial thought was to create an http connection and send a POST request to the website. I read briefly about creating a web API application that would handle this.

Are there other "standard" or preferred ways to solve the problem?

I'm looking for an efficient way to do this along with testability.

/ If anyone ends up here, you can check the result of this / https://github.com/egenvall/ConsoleToBrowser

+3


source to share


2 answers


I suggest you go through SignalR

http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr



  • You need to create a service that should expose the content to the console

  • From your web application, use SignalR to call the service. This will display the data sent from the service on the screen without having to refresh the user's screen.

    When calling the service, it has to bind the data to the screen and store it in the database.

+1


source


You can use the GET method to send data from the console, open port 80 on your webserver and send:



GET /page.aspx?id=12&data=test HTTP/1.1<line feed>
Host: your.domain.com<line feed>
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)<line feed>
<line feed>

      

+1


source







All Articles