GraphQL support for ASP.NET WebAPI - c#

Is there support for GraphQL and classic dotnet i.e ASP.NET WebAPI and not dot net core.I searched that on internet but did not find any useful resource.
We have exsisting ASP.NET WebAPI where we need to select and update few columns based on request received to API.so in that case we can use GraphQL. But I did not find any resources related to it.Everywhere is dotnet core apps.

If I recall correct, one of most popular lib GraphQL.Net under .Net stack, supports .Net standart 2.0 which means you can build and use it not only under .Net core (target framework should be at least from v4.6.2). At least I did it in one of project (not .net core one) successfully.

Related

adding a web app project to my solution, and the other projects in the solution already use .net framework, can I use .net core for the new project?

Ive build out a service as a console application, it exists across 2 different projects in the solution, both are in .NET framework. I am wanting to add in an api level to this and am wondering if I should continue to use .NET framework for the web application project, or if I can use .NET Core without messing anything up.
It all depends on the APIs you use in your application. If you only use APIs included in .NET Standard then no problem to use them in an application under .NET 6. Otherwise I join Kirk Woll to migrate your code under .NET 6 especially since the unification of the platform. I think it will remain only .NET 6 aka .NET core in the future.

Setting valid produce and consume media types in swagger for MVC5 in .net Framework 4.7 (NOT ASP.NET Core)

I see many examples with ASP.NET Core that explains on how to set valid produces/consumes media types using swagger on ASP.NET Core MVC but I am unable to figure out how should I set the valid produce/consumes media types on MVC 5 running on .net framework 4.7. Please Help.
I tried using [Produces("application/JSON")] attribute but system complains about Produces attribute not found. I think this is specific to mvc in .net core and not for .net framework 4.7. I have installed swashbuckle Nuget package only. Do I need to install any other package?
Thank you.
I used a variation on this example,
https://blog.kloud.com.au/2017/08/04/swashbuckle-pro-tips-for-aspnet-web-api-part-1/
I implemented ProducesAttribute and ConsumesAttribute decorators, and looked for both decorators in an IOperation.Appy filter method.

Is there a way to add and start a .Net Core 2.0 REST server inside a .Net Framework 4.5.2 (or .Net Framework 4.6.1 or .Net Standard 2.0) application?

Issue
Hi,
I am currently working on implementing a RESTful API in C# using ASP.net Core 2.0 in Visual Studio 2017 (running only via Kestrel, therefore no IIS).
Everything works pretty well, no issues there. The thing is that I now need to integrate and start this REST Server in another project (The REST server being only one of many functionalities that need to be executed at the same time, using a "bootstrap"). My issue here is that the latter project targets .Net Framework 4.5.2 whereas the REST server targets .Net Core 2.0. Thus, when I add the REST server to the references of my bootstrap application, I encounter a couple of errors saying that some of the Nuget packages target the wrong framework.
Solutions I tried
I searched over Google but most of the issues I found were people trying to do the other way round, i.e. adding a .Net Framework-targeted project in a .Net Core application.
The way I understood this .Net implementation support table, is that a .Net standard 2.0 project can support a .Net Core 2.0 project (I am probably wrong).
I tried a couple of things to make it work (which, spoiler alert, obviously and unfortunately did not work as I wouldn't be asking your help) :
Made the boostrap application target .Net Standard 2.0
Made the boostrap application target .Net Framework 4.6.1
Made the REST server application target .Net Standard 2.0 (which it of course didn't work, but I was kind of desperate..)
I made these target change by modifying the .csproj files.
I don't have the exact error codes because I reverted my changes a while back but they all were about projects not targeting the same framework.
So, in a tl;dr manner, what I am asking is :
Is there a way to add a .net Core 2.0 REST server inside a .Net Framework 4.5.2 (or 4.6.1 and higher/ or .Net Standard 2.0) project to start the server inside the application ?
Apologies for any english mistake as it is not my native language.
Don't hesitate to ask more info on my problem if I wasn't clear enough and thanks for the help !

Azure function with .net core 2 class library

Since there is still no support for Webjobs in ASP.Net Core, i am going to use Azure functions instead.
I have 2 class libraries that are build with on .net core 2. i can reference them to my Azure function project without any issue but when i try to publish i get this error.
This is the reference from the Azure function to my lib
Any idea on how i can make this work? without changing my class lib?
Azure Functions doesn't currently support .Net Core 2 (more specifically, .Net Standard 2), however, it seems like the team is actively working on getting this support out...see here: Port runtime to .NET Core
Runtime will be ported to target Netstandard 2.0.
Depending on the functionality of your libraries, you may see if its possible to target instead Netstandard 1.3 which they do currently support
This issue will track the .NET Core port activities for porting the runtime to .NET core. Note that netstandard 1.3 assemblies can be used on Azure Functions and this is fully supported.
Update: added clarity based on #derape comments
.NET Core 2.0 is now supported by Azure Functions.
https://blogs.msdn.microsoft.com/appserviceteam/2017/09/25/develop-azure-functions-on-any-platform/
Since there is still no support for Webjobs in ASP.Net Core
My understanding is that the VS tooling is not ready yet, so you cannot have a project template targeted at that, or some easy Publish as webjobs menu item.
But as far as I got reading through blog posts, you can create a .NET Core console application, add some .cmd file to project root with content like:
REM run.cms - Webjob entry point
#echo off
dotnet MyNetCoreConsoleApplication.dll
include that in the set of published files (with project.json "publishOptions": { "include": [...] } and finally make the webjob point to that cmd script. See for example here, or search for azure webjobs dotnet core.

Which class library type do I use with a Core 1.0 RC2 (.NET Framework) Web App

In ASP.NET Core RC2 Microsoft split the Core web application into two separate templates:
ASP.NET Web Application (.NET Framework)
and
ASP.NET Web Application (.NET Core)
I am planning on developing an app that is net 451 only. If I go the (.NET Framework) path. What type of class libraries should I be using? I assumed Class Library (.NET Core), but when I tried adding reference from a project with the (.NET Framework Template) it says it can't add reference to .NET Standard.
Maybe I shouldn't be using the .NET Framework template. The main reason why I feel like I should be is because I do not want to have to deal with developing for the other operating systems and not having access to certain packages like email and transactionscope, etc..
If you set your class library to target net451 also it will work.
Change project.json in class library project as follows...
"frameworks": {
"net451": { }
}
As I understand it, .NET Standard can reference .NET Core libraries, but .NET Core cannot reference .NET Standard libraries.
So, it comes down to the end-use of your application. If it's only going to run (or be hosted) on Windows, then use the larger, more established .NET Standard for the application (although you can choose to put common code in .NET Core projects in the same solution for future cross-platform re-use). However, if there's a requirement to run/host it on another platform (Linux, Mac), then you'll have to use the younger .NET Core.

Categories