Web.Api 2 and Asp.Net core in one solution - asp.net

Currently we use ASP.NET core project for our UI. There is need to add an OData service to it. As far as I understand it is not supported well enough yet, so it was decided to implement it in a separate Web.Api 2 project.
Is there someone who has such an experience?
Is it a way to go?
May I encounter troubles with deployment to Azure?
Any ideas and thoughts would be appreciated.

If you hosted the web site on a different web application, then you have to enable CORS on the web API, and you have to test it during development to avoid any issues.
You can overcome this issue by deploying both the UI and API to the same Azure Web App. you can have the UI under the root and the API under a virtual directory, ex: apis

Related

Where to host a proxy app with YARP to migrate from .NET Framework to .NET Core?

We have a big ASP.NET Framework application hosted in IIS and we are considering a progressive migration to ASP.NET Core using YARP, as explained here: https://devblogs.microsoft.com/dotnet/incremental-asp-net-to-asp-net-core-migration/
The basic idea is to deploy a ASP.NET Core app that will proxy all the requests to the old application, and then move the code progressively from the legacy app to the proxy, until the legacy app is empty and can be removed.
We are wondering about the hosting of the ASP.NET Core proxy app. In priciple there is no limitation, it could be deployed in IIS alongside with the legacy app or be deployed with Docker/Kubernetes. However, we don't know if that second option will cause a performance penalty or any other kind of problem. So before doing a POC, we'd like to ask if somebody has experience with this problem and some advice about it.

Integrate Angular JS project into Web Api project

I currently have a Play project where Angular Front-end is integrated into it with Gulp. Now I need to re-use the angular code into a .Net Web-Api project. Having APP and API as separate project will work. But to avoid dealing with different ports and CORS only option is to have one project that is deployed to one port where AngularJs project gets integrated along with Web Api project.
I have checked many question only this Stack-overflow answer seems relatable to my scenario but no luck with that solution too.
Does anyone know how to do that kind of integration. And is it possible to have integrated both into one project
Create ASP.NET MVC application.
Change default Index.cshtml with your index.html from Angular application. (You'll maybe need to correct paths to other files).
Now ASP.NET runs your application so you can add WebAPI Controllers instead of MVC Controllers inherit from ApiController.

ASP.NET Core Web API living inside a ASP.NET 4 IIS Web Site

I am tasked to to build a Web API application. The app will be hosted inside an existing web site - a pre-ASP.NET 5 web application with a WCF web service.
I wonder - can I build the web-api application using ASP.NET Core 1 in a way that it can happily exists as a sub application inside the already existing site in IIS?
Thanks!
Yes, this is possible, I'm doing the opposite of this scenario but conceptually its the same thing. You need to create your subsite as a separate application in IIS with its own app pool. That app pool needs to be configured No Managed Code per the instructions on the Docs site https://docs.asp.net/en/latest/publishing/iis.html
The only other thing you need to watch out for is that the web.config in the subsite will inherit some settings from the root web.config, so you need to remove or clear things sometimes like handlers, modules, etc.
If I understand you correctly it is not possible what you want. Please refer to the following documentation about hosting ASP.NET Core on IIS: https://docs.asp.net/en/latest/publishing/iis.html.
If you specifically look at the .NET CLR version in the application pool it should be "No Managed Code" while your current website is set to a .NET framework version I assume. This is because ASP.NET Core is now cross plaform and completely web server agnostic. It even needs a little 'trick' (the ASP.NET Core Module) to work on IIS. See: "The module creates the reverse-proxy between IIS and the Kestrel server."
But if you follow the link provided above I think you'll manage to work it out.

How to integrate .NET web application project (API) with Apache Cordova Project?

So this is the issue:
I have a .NET project that includes 5 Web Application Layers.
One of them is API.
I Recently added a Cordova project as well and I'd like it to communicate with the API Layer.
Is there anyone who knows what to do?
P.S.:
I use visual studio 2013.
You can use normal jQuery Ajax calls to make requests to the API. http://api.jquery.com/jquery.ajax/ or just normal JavaScript ajax https://stackoverflow.com/a/8567149/487940.
I hope that answers your question.
If you're talking about calling into Web API web services from a Cordova app, you may find the Breeze.JS framework useful to help you. You can either just used the client library or use some server side code in addition to client code to help get you up and running and exposing new web services as well.
Otherwise it is simply a matter of making web service calls to the server from your JavaScript code but the specifics will depend on exactly what you're trying to do and what client UI/utility framework you are using.

ASP.NET Web Service on localhost?

At the minute I am building an ASP.NET MVC application to learn the technology, and I want to incorporate web services as I have never used them before and I want to have experience with them.
I was wondering would it be possible to create a web service and run it on the Visual studio local host along with my MVC application an then consume it with the MVC application.
I am hoping that the web service will basically pull data from the the same db as the app and then allow the mvc app to consume the service. Would this be possible?
Sorry if this is a pointless question but it is for a college project. Any help greatly appreciated
Thanks
Yes, it is very possible with Visual Studio - in fact, it is easy. Best to follow some tutorials - one such tutorial is http://www.asp.net/mvc/tutorials/mvc-music-store.
For more specifics about the service from within VS, this link may be more helpful - msdn.microsoft.com/en-us/library/cc668184(v=vs.100).aspx
If you are talking a WCF service, this is very easy to do. You'll want to add the service to the same solution as your MVC project, right click on References in the MVC project, then click add service reference. On the dialog that comes up, click discover to the right and it will find the service in the solution allowing you to add it locally.
Once you have a service reference, you can right click and configure to see the path. Should be set to localhost in this case. Doing this will allow you to set breakpoints and debug the service through your MVC application.

Resources