Can you build an ASP.NET Web API on top of OWIN? - model-view-controller

Well the title basically sums it up, I'm wondering if I can create an OWIN pipeline to my ASP.NET Web API. I want to do this so I can apply a base security layer that I can apply to all of my API service hosted on my service server. New to OWIN, love the idea

Yes. You can start with this http://nuget.org/packages/Microsoft.AspNet.WebApi.Owin/0.21.0-pre and then you will need an another package depending on what host you choose.

You will find below link helpful. It using Katana, an OWIN implementation for Microsoft hosts and the Web API framework.
http://www.strathweb.com/2012/12/running-aspnet-web-api-with-owin-and-katana/

Yes.
Also: If self-hosting Web API 2 using OWIN in a windows service, you can check out this example on GitHub: https://github.com/danesparza/OWIN-WebAPI-Service
It walks you through creating the service, adding OWIN using NuGet, and using attribute based routing in Web API 2.

Related

Microsoft Graph API IN n a Web Forms application

I want to use Micrsosoft Graph Api in a web forms application, although there are only tutorials of Microsoft Graph API in a console application or MVC applications.
I saw this tutorial explaining how I can use the Web Api in a web forms applications. https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/using-web-api-with-aspnet-web-forms
I wonder if the same logic will work with Graph Api. Do I have to create a model and controller in Web forms to use Graph Api?
I hope I explained it well.
Can someone advise please?
Thank you very much in advance.
If you want to call graph api in your c# project, then you need to make sure you have an azure ad application first with the correct api permission.
Then you need to install 2 packages into your application, and for example using client credential flow to call graph api, this is my test result.

Secure ELMAH in Web API 2 project: Share Authorization code

I am using ELMAH in a Web API 2 project. I wrote my own IAuthenticationFilter to authenticate against Atlassian's CROWD.
I want to secure ELMAH also against CROWD. Is there any way to achieve this?
Are you wanting to make a secure Web API call that shows the most recent or the most common errors in your ELMAH data store? If so, why not write those data-fetching calls and secure them with your custom filter the same way as your other API calls.

How to convert an existing ASP.NET Web API to Azure Mobile Service?

Recently announced at Microsoft Build is the ability to convert an existing ASP.NET Web API to an Azure Mobile Service. I was curious as to if anyone has successfully done this yet, and the steps needed to do so.
Things I've tried thus far:
Added the Azure Mobile Service .NET Backend & Azure Mobile Service -
Entity Framework Nuget Packages to my existing ASP.NET Web API
project.
Resolved an issue with OWIN and AMS(ZUMO) conflicting Startup.cs assemblies.
Ensured the ASP.NET Web API compiles locally, and published as an Azure Mobile Service.
However whenever publishing, it seems I only get a runtime error on the server.
Here was the best example of potentially doing this: http://channel9.msdn.com/Events/Build/2014/3-623
Secondly I've looked a bit into just running the OWIN pipeline via: http://www.strathweb.com/2014/02/running-owin-pipeline-new-net-azure-mobile-services/
I know that this is in a preview mode, but figured some document trail would help!
Can you try adding your existing WebAPI assets to Mobile Services project you create from VS? This will make sure all the right things are wired up. Also, check the Logs tab in the portal for any clues.
This should help..
http://blogs.msdn.com/b/azuremobile/archive/2014/04/10/creating-an-azure-mobile-services-net-backend-from-scratch.aspx
Thanks
Supreet

Using own domain model/entity on client with wcf data service (uses web api/odata/entity framework) as service reference

Here's my situation, I'm trying to create a WPF application that connects to my own web odata service (uses web api and entity framework). I have my own set of domain models/entities in the server side that the web api and entity framework works with. When, I add the web odata service reference in the WPF client side, it can't recognize my own domain models/entities and it looks like it creates its own set of it. Is what I'm trying to do even possible or am I just missing something?
Regards,
Raymond
Drive-by answer (unchecked): I remember reading that it wasn't possible at least a few weeks back. You might want to search the Uservoice site and the official forums for current status, or wait for a better answer here.
It looks like this problem is currently a feature suggestion for WCF Data Services (thanks to tne's uservoice link). The direct link to the request is https://data.uservoice.com/forums/72027-wcf-data-services-feature-suggestions/suggestions/3220086-allow-re-using-entities-from-another-dll-on-the-cl.

asp.net MVC Web API VS asp.net MVC 4 & MVC 3 internet application

i read about the beta version of asp.net MVC 4 web API , i think that it is related to building web services. So are these two frameworks (MVC 4 internet application & Web API) targeting different types of application or they may be used for building similar types of application but using different frameworks?
for example if i need to build an internet application for a registration system for a university or an internet shopping store (which i use to develop using asp.net MVC 3 internet application),, then will these two frameworks be suitable for these types of applications ???
Thanks for any help ...
BR
Those are just 2 templates. No matter which one you choose when creating the application initially you could always later change and add functionality. The MVC 4 internet application template is similar to the ASP.NET MVC 3 internet application template. It creates a default Home and Account controllers, it registers a default route and adds a couple of views.
The Web API template in addition to all this it adds an API route and an ApiController allowing you to expose RESTful APIs in your web application. The Web API is basically a simplified way to build RESTful services. Up until now this was possible with WCF but the Web API makes it really simple. The Web API could be self hosted. You don't need to put it in an ASP.NET MVC application.
The webapi makes it simple to create HTTP services. I have only used them to return json. You can use either for the types of applications you are building.
Take a look at this blog article from Scott Guthrie http://weblogs.asp.net/scottgu/archive/2012/02/23/asp-net-web-api-part-1.aspx
Web Api basically lets you create HTTP REST full services. The API also gives one full access to the http requests and responses in a type safe way.

Resources