Add ASP.Net to existing project

I’m new to ASP.Net and I have the following scenario:
I have a .Net Framework project folder with several projects. All of them are configured .Net Framework 4.7.2 and I have a dependency I can not change at the moment. So migrating to .Net Core is not an option at the moment.

My question is the following:
What is the correct approach to add the functionality of a RESTful server with ASP.Net?

I don’t want to implement a frontend. I just want to add a server to my projects.

In
https://docs.microsoft.com/en-us/dotnet/standard/choosing-core-framework-server
it says, “In most cases, you don’t need to migrate your existing applications to .NET 5. Instead, a recommended approach is to use .NET 5 as you extend an existing application, such as writing a new web service in ASP.NET Core.”

How should I do that?

I’m really confused. Please help me.
Maybe some hints or links to other pages are enough to lead me into the right direction 🙂

Kind regards
Chris

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It basically depends on your future preference and time, If the organisation is pretty much aligned with .netcore what you can do is you can easily migrate .net framework project to .Net standard and create a new .Net core project with API endpoints defined and you can easily refer the .Net standard libraries directly to it.
https://docs.microsoft.com/en-us/dotnet/core/porting/

But if you want to stick to .Net framework libraries, you can create basic Asp.Net core web API with DotNetframework, It is not a legacy framework, it has the latest release within 3 months and it is also battle-tested, But you can only host in windows machines unlike .Net core which you can host in windows/linux

https://developer.okta.com/blog/2018/07/27/build-crud-app-in-aspnet-framework-webapi-and-angular

Method 2

any .net project that running on a web server supports REST calls. In fact if you make a webmethod?

Say this code:

<WebMethod()>
Public Function HelloWorld() As String

    If keyid <> 123 Then Exit Function

    Return "Hello World from server"
End Function

Then right out of the box with ONLY the above code?
The above supports SOAP 1.1, 1.2, and post (REST) calls.

So there is no “concept” in asp.net that you “adopt” SOME kind of RESTful server – the server you use in this case is IIS, and it supports REST calls out of the box, and always did from day one to my knowledge. You MOST certainly have to run a web server, but making REST calls does not require a “special” RESTful server, but just in fact that you running a web server – in this case IIS or so called internet services.

Method 3

If you already have a project that supports and API just add an additional controller, assuming the functionality is not closely related to existing functionality.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x