asp.net - Get data from external application - c#

I would like to know how to link my web application with an external application.
The external application would call my application with a link.
Ex, ../../report/3
here 3 is the id for some data. Now I would gather the data from their database and process it.
Please tell me how to achieve this. What would be the best approach?
I am not started yet. Looking for an idea to start.
Thanks in advance.

Read about RESTfull services and JSON.
Alternatively you can return a JSON (or XML) according to a query string sent from a client.
If you want some security read about WCF and for older .net you can check out the older Web Services of asp.net
Good luck

Related

Restful asp.net api and using json in android application

I use this tutorial to create a restful asp.net web api for my android application, everything goes well and seems well, but my android application (based on tutorial part 2) can't communicate with db and always return 0 when I fetch some data.
I should mention that I use linq for connecting to db and in my api service I return a list of object (List)...
I need some way to test my api , is there anyway?! For example call api from browser or something like that to see the json array that return...
Also I have a question about the dll in the tutorial. Are they safe and okey?!
If anyone have better solution to have the functionality like the tutorial ones please suggest me...
Thanks in advance.

Prevent unwanted access to my web service

I have coded a C# MVC5 Internet application and I have a Web API 2 web service that returns JSON data. I am retrieving this JSON data in an android application.
How can I add a feature to the web service such that only my android application can retrieve the JSON data? I am wanting to do this so that other web users cannot hammer the url and the web service will not send my data to unwanted applications and/or users.
Is this possible? If so, how should I do this?
Thanks in advance.
You have various ways to achieve this in fact.
For example, you can store a key in your android application and use send this key together with the request to your WebAPI. Your webAPI will than check if they key is valid and if it is, it will return the JSon.
However, there's no way to ensure that nobody else can request and get your data. For example by reverse engineering your android application and extracting the key, or by monitoring the network traffic and find the key in there.
You need to understand that there isn't anthing that guarantuees you 100% security.
See it as the following:
You have an open door right now, you can close it little by little, but closing and locking down is not possible. There will always be gap. A house also can't by made burglar proof, but you can make it very hard for a buglar to enter.
Go to this link Web Api. I have used the individual authentication for my web api. When you will register the user the response you will get is access token and use that access token as Authentication header in your ajax call if you are using Jquery ajax to call your Web Api. Refer this The OAuth 2.0 Authorization Framework. Hope this help you.
Are you looking for something like this?
http://httpd.apache.org/docs/2.2/howto/access.html
If you have other web server, there should be appropriate means to support such.

Consuming IIS-hosted WCF Service from Linux Web Application

I was tasked at work to create a web application (viewable in Firefox on Linux!) that displays results in a tabular format using data exposed by a WCF service (written in C#) hosted on a separate Windows 7 machine on the same network. Rather than returning formatted HTML, the WCF service returns structs and it will be up to the client application to take these objects, pull out the data, and format it.
Unfortunately, it has been a couple years since I have worked with any sort of web technologies. What is the best approach to solve this problem? Is there anything more current than REST/AJAX/JSON/jQuery technologies? If anyone can point out some helpful and current resources on the proper way to accomplish this, it would be most appreciated.
Use a SOAP framework to consume the WCF service. Configure WCF to use SOAP (one of the HTTP-bindings).
Webservices are easy to consume these days thanks to a standard RPC format (SOAP) and libraries supporting it. You can surely find a SOAP client for any language you are proficient in.
Checking back in here to report my own solution for this problem. I ended up going a bit of a different route that produced the simplest solution for the situation. Instead of consuming any services on the Linux side, I simply made an ASP.NET website on the Windows/IIS side (where it is easy to consume the WCF services right from Visual Studio), and then just render the website on the Linux side via the URL in a Firefox browser. For me, that fulfilled the customer requirements and was perfect, although this may not be the best approach for others that need to work with or manipulate the data in some way.

Returning JSON from WCF after POST in Android

I just started coding for my android application and I am unsure of how I should start coding.
If I want to do lets say a login in my android application. How should i start?
Is it possible if I do it in this way:
Send POST to my WebService > Web Service Validates credentials > Return user information
Please help!
Yes your process is correct.
If you have simple needs like what you describe using the default serializer should be enough, just specify:
WebMessageFormat.Json
Later if you need a full fledged JSON library use Json.NET
A small tutorial to get you started (it uses a similar use-case): http://www.codeproject.com/Articles/167159/How-to-create-a-JSON-WCF-RESTful-Service-in-60-sec
Do not forget to use authentication over HTTPS only...

Best way to authenticate from C# WPF on PHP website

I am writing a WPF application that I need to authenticate with our current PHP based online website. I have full control other both, so any recommendation is possible.
I do not know whether it would be best to use:
Pass the username and password via post/get to an API and see if the user is "valid"
Connect to the database directly (probably not a good idea)
JSON or XML?
A few suggestions:
For security and communication between client and server use the WebClient Object, Or, if you wanna go pro, search a web service generator for php and work with web service standards.
only the server should be able to communicate with db, security, abstraction and orthogonality are good reasons for that.
Json makes the data thinner, so it's recommended, but if you don't care about data size, xml can be directly bounded to wpf controls, maybe it can help you.

Categories

Resources