Analyzing the Web API Traffic - asp.net-mvc

I have custom Web API been hosted and exposed. I want to know how to get details like who accessed my Web API, time of accessing,etc. In short I just want to know my Web API usage history.
Can it be possible? If so, can you please help me in this context for where to look and so?
Thanks

You can use System.Net.Http.DelegatingHandler to accomplish logging. As a start, have a look at the following blogs:
Log message Request and Response in ASP.NET WebAPI.
ASP.NET Web Api–Request/Response/Usage Logging
and this for an alternative using an ActionFilter
Implementing Audit Trails using ASP.NET MVC ActionFilters

Related

ASP.Net web API services usage

There are two separate projects. I want to run asp.net mvc projesine with service.
I would also like to use the web api service as a service.
How can I make the connection between Asp.net MVC and Asp.net WebApi. I will use the controller in the web API.
Can you help me?
Ideally , You can Call them Even if they are In a Separated Projects
as long as they are in the same solution,
Specify the Route To the Api and it will work,
if they are NOT on the same solution you can ingrate them to gather or host them both on a local host and use https://localhost:"The-Port"/{Route}
Hope that Helps ,

Separating Web Api and Web Site

i'm new to asp.net web api, owin, and everything related to it.
I'm trying to find the best way to do this scenario:
1 - Web api to have all the connections and rest service
2 - Web site to show data to user on a browser using the restful service
3 - An mobile app that have some functionalities like the web site and access the restful service to get all the information
My doubt is: what's the best practice related to the login? I'll use owin/oath2 with Identity to login, but since it's going to be implemented on the web api, the login/register/forgot password should be on the web api directly (like the project template does) or should i move most of the functionality to the web site? Of course its easier to leave in the web api, but if i do it, i must duplicate my razor templates just to call the login part. Can someone give me a path to follow?
Thanks!
the answer is not, your web api should not have any html or js or css file, only the services that your need, the web api exposes the functions to register the user, next when you have to do request, you must Send a token, you can obtain the token using the URL that you have configure in owin, the URL is like /token and Send the username and pass.
Regards,

Asp.Net MVC and HTML5 PUSH notification

I would like to have server side event in a full HTML5 application.
Server side I've an asp.net MVC3 web server, which gives HTML pages and JSON results.
What is the best way to integrate some server event? Like a process which can send some text message to client?
I've made some search and found something about a Asp.Net web api, but I don't know what it is and if I can use it with MVC.
You should have a look at http://signalr.net/ library. This blog post is also very informative.
SignalR looks very interesting, but maybe more than you really need. I've often wondered why people don't use Server-Sent Events more often, I haven't had the chance, but it looks like the simplest way of implementing.
Here is an example in MVC if you want to review: http://blogs.microsoft.co.il/blogs/gilf/archive/2012/04/10/using-html5-server-sent-events-with-json-and-asp-net-mvc.aspx

ASP.Net MVC4 Web Api with Help Page of WCF possible?

I am starting to develop with Web Api MVC 4 and created the whole stack. My services are working but I wonder if it is possible to see a Help Page similar to what exists on WCF.
Does anyone know?
Thanks
Checkout the ASP.NET Web API Help Page which is available as a NuGet package:
http://blogs.msdn.com/b/yaohuang1/archive/2012/08/15/introducing-the-asp-net-web-api-help-page-preview.aspx
Not currently but this is in the MVC 4 roadmap:
http://aspnet.codeplex.com/wikipage?title=ASP.NET%20MVC%204%20RoadMap
Web API Help page generation: We want to make it easy to generate rich, web-based documentation
for your web APIs, including the resource URIs, the allowed HTTP methods, expected parameters, and
sample message payloads.

How to use SOAP in asp.net mvc

A 3rd party site sends its notifications after my web application has completed some action in order to notify me of its success. Receiving a notification item requires a response back to the 3rd party server (URL) with the a containing the value "accepted".
I have never user SOAP and with the basic info found I'm a bit lost for the case of asp.net mvc. Are there any good links showing the principle of receiving and sending SOAP responses?
Tutorials / information may be presented in other languages such as java, asp.net (classic) or something. I need to get a general idea since googling on SOAP has not given me anything for the past few hours.
You need to learn a little about WCF. See the WCF Developer Center, especially the Beginners Guide.
What you want is to create a simple WCF service that corresponds to the WSDL that they will give you. You will need to implement only the operation (method) that they will call to notify you. You can host a WCF service in IIS along with the rest of your application.
The issue will be how to correlate the notifications with the page you're on in your MVC application.
I don't think this is specific to ASP.NET MVC really. If you have a WSDL for their web service, just use that to generate stub classes using either wsdl.exe or by adding a web reference to your project, then call the web service from your controller.
If I remember correctly SOAP is basically xml requests and responses.
You might want to look into WSDL (Web Service Definition Language) to avoid having to deal with raw data, and you would likely find a great deal of tutorials on wsdl as well.

Resources