I'm developing a project that based on columns from a database tables as to present a dashboard.
I've been told to create a Web Api project (added to a windows form project) to obtain the columns data and work it to present the charts.
My windows form project is project1 and the web api is project2.
The idea is when I click a form button, I'll present a html file with the charts. My line of thought is when I press the button project2 will start, with the data already collected in project1, to present a dashboard.
If I'm thinking correctly, my questions are:
How can I call the web api when clicking a button
How can I pass the information already collected to project2
May be you not explaining something right or I don't understand something.
Looks like you adding a Web Api project as part of the solution. Looks like you have some data at Windows application, which then being posted via Web Api to database. If this is correct then:
Web Api is .NET web-centric framework for REST, in which HTTP stack is at the center. In REST you have stateless application running on the web server and you making calls to it. The beauty of REST is that the client can be practically anything - any device, any application, another REST service - anything!
The answer:
So, your Windows App can make a call to your REST layer and post data. In your Windows app you will need to reference System.Net.Http to use HttpClient class. Using this namespace you can compile Http messages and make Http Requests and receive Http Responses.
I think, this is exactly what happening in your solution. Please let me know it it is not what I think.
Related
can u please help me out with the best solution how to do this?
I have a windows form application, which is continuously doing something. (making screenshots and generating data) This app is running locally.
So I dont want to use teamviewer from office just to see what my application is doing. I want to create an AngularJS Web Dashboard application (load it on a webhost) and display this winform data (in form of charts,..), so that I can access from everywere.
What is the best solution for this?
I have experience with AngularJS and parsing JSON-Files from a webserver.
I preffer creating/serialize a json file (each second) from my winform app and load it somewhere on webhost and then access this json file with http.get from my AngularJS application.
Is this a possible solution? Any suggestions?
Thanks!
I agree with making a Angular web app (although you don't need angular for this, you can use jquery to make a simple ajax call, seems like it would be quicker to add the jquery reference than to setup the angular scaffolding just for one or two ajax calls) to call a web request where the winforms app stores the data.
Ex. you can create a web request (or directory save) in winforms app to perform the 'snipping tool' action described here: C# snipping tool service and send the data to somewhere to store it. If the snipping tool doesn't work then probably use an export of the chart or data you are capturing. Then the web app can query that directory to retrieve (ajax/http get) whichever data you need.
I would advise clean up on that directory as it could become quite big if you are saving to it every few seconds or so.
I am developing a system comsisting of two ASP.NET projects. The first project is only accessible from a local IP and holds all the methods and has access to the database. The second project only consists of a userinterface and should get the needed data, by calling methods in the first project, which returns the needed data. The second project, is available from any IP.
My question is, how can I connect these two projects, so that the second project can access methods in an object, in the first project, using ASP.NET?
I have tried with JQuery and AJAX, but with those, I can only access static methods.
You can use a "Generic Handler" (a .ashx file).
With this you can expose a HTTP endpoints.
You should convert your first project to a Web API Project which has endpoints exposed to clients to do different things over HTTP protocol. You will call these end points from your second project.
Your first project will act like a web service which does all the business logic and database things. Your second project will be thin UI client, which will communicate to the first as needed for getting data,updating data etc.
You can use HttpWebClient class in your first project to communicate to the end points of your Web API project.
I'm trying to understand if there is a way to make a web application run on the local computer(browser) without IIS.
My main objective is to transform my web application (that is on the internet) to a software that runs on the local computer without using the internet and without IIS.
My idea is to distributed my webapp between my colleagues and not forcing them to work online and not needing an internet connection.
I have a MVC web app with 3 pages and a couple of methods on the server side.
The idea of the application is to get proprieties from a form that I implemented on one of the pages of my web application and transform the proprieties on the client side to JSON and send it to the server, the server will generate XML file according to the JSON object and let the client download the XML file that were generated.
The flow of it:
1.The Client fill the form in my site.
2.The form become JSON object on the client side.
3.The JSON object that stored the properties of the form(filled by the client) is send to the server.
4.The server get the JSON object and generated XML document from it.
5.The client download the generated XML file.
Very simple web application.
I know that I can run HTML page by clicking it and the page will display on the browser but I need the server side to be working too to carry out actions.
So my question is : How can I make my web application run without internet ?
With the constrains:
No IIS required.
Working with .NET 4.0. (OWIN 2.0 - Not good)
No internet require.
No installation required to the computer ill pass this web app.
The server side code wont be expose when I send this application to my friends.
I read a couple of articles about OWIN, SingalR, Cassini and WCF but its all very vague...
If someone could provide me with a guide lines it will be very helpful.
Thanks a lot.
You can definitely self host a .NET web application using OWIN. Unfortunately documentation and information about it is vague and confusing at best. The fact that you're using MVC makes it somewhat easier as you may be able to directly use the self-host packages from Nuget for self hosting Web API. There may be similar packages for MVC.
I don't have recent experience but a Nuget search for "MVC Self Host" should yield some results.
Below is a link with an example. But the term you are looking for is definitely "self host". It can be done via a console window or (more complex) a windows service. It will likely use some form of OWIN but you can probably find some startup code to copy and paste into your project, usually in the form of a Startup.cs file.
http://www.c-sharpcorner.com/UploadFile/4b0136/working-with-owin-hosting-and-self-hosting-in-Asp-Net/
EDIT. I was adding it as a service reference instead of a web service reference (found by when adding a service refererence, go into advanced and down the bottom it should say "add web reference") , I didn't know that option existed as it's hidden away.
I made a web service in c# .net. Initially it wasn't calling because I thought that the web form didn't like the codebehind for the web form that is created in VS2012, so I took that out and just included the web service file itself.
I'm pretty sure the libraries were included when I visit the url of the service with wsdl, but it still won't seem to call the service to the form.
It displays some XML data and shows TestCypher as a workable service, so it should be working? I'm not entirely sure where the wsdl file should be hosted if I take the web service out of the solution
Please see the below link
http://www.codeproject.com/Articles/26941/Consuming-Webservice-In-A-Windows-Application
you can use this method in your application. I just post this example in your requirement.
please note : i have no guarantee about the perfomrnce area in this method.
So please consider this element when your application is use a wide number of users.
Hope it help.
On the ASP.NET server (production), I am told to use the web service that is written by some other person.
Question is how do I find out what webservices were deployed on the production server. All I am told is to make a call using "CheckFile" (which I believe is a part of the web service). I went to the Inetpub folder to see if there is any folder that has these webservices but there is none?
Sorry I am doing this first time and hence many questions,
My end goal is to use these webservices in my ASP.NET application and call those functions such as "CheckFile" and others from this webservice.
Thanks.
I agree ask your co-worker if you have one.Else if you have access to old asp.net app then right clik on project and click on service reference tab it will show web services in that .net app.