tags:

views:

28

answers:

2

I'm new to asp.net mvc and web development in general and would like to know the best way to pass text from a windows application written in c# to a asp.net mvc website so it can be stored in a database. Is it possible to call a controller action (via a url similar to REST) from the Windows application or do I need to create a web service? If someone can point me to a verbose example that would be great.

Thanks

A: 

You can use the WebClient class. Look here for a simple sample.

Hope this helps.

Hemme
Thanks for the response, Hemme. I did a POC using the WebClient and it worked well. My only concern is that while I was Googling for more information, I discovered that many people were having issues with the WebClient. Nevertheless, I'm going to implement the WebClient based on it's simplicity and the success I had (although I'm going to do it so that I can easily swap it out in case I run into problems).
fynnbob
A: 

Why do you want to pass it to your MVC site to store in the database? How are you interacting with your database in the MVC site?

If you have two different applications that need to access the data you should put it in a separate layer and may be create a WCF service or a Web Service.

Ritik Khatwani
Thanks for the response, Ritik. I don't have to pass it to an MVC action, I'm just looking for the best solution based on how the website was developed. If an argument can be made for one way over another (such as passing a string to an MVC action method versus using WCF or a Web Service) then I'm open to it. My current requirement is simply to pass string data to the website and store it in the db (which is SQL via the Entity Framework).
fynnbob