Host Asp.net Core Web Api locally - asp.net-core

I am learning Asp.net Core Web Api. I need to access the api from a flutter application but am not ready to host the api on Azure. What are my options if I want to host the api locally on my computer so I can access it from another application like my Flutter app client, and is there any tutorials I can follow to learn how to implement the solution.

There are several ways to go about this, here are some options:
FROM VISUAL STUDIO: You can simply run the ASP.NET Core Web API from Visual Studio in Development Mode by Pressing F5
FROM COMMAND PROMPT: Run the API Project from the command line by opening a command prompt window in the root project folder of the project and use the dotnet run command. See here for more info about the command: dotner run command
HOSTING IN IIS: I am assuming you are running a windows OS. You can turn on IIS and its features. Simply follow the instructions on this page: Host ASP.NET Core in IIS on how to deploy ASP.NET Core to IIS. The advantage of this is that you have the application always running while you work on your flutter application locally.
I hope this helps you resolve your situation.

What are my options if I want to host the api locally on my computer so I can access it from another application like my Flutter app client, and is there any tutorials I can follow to learn how to implement the solution.
If your application is developing now, there is no need to host the application and let the Flutter app client to access. We could build some json file as the right format like web api response to develop the client app.
If your client application and web api has now developed successfully, you want to host the web api to let fluent app or other application to access from internet. You should have a public IP address and host the application on IIS or else. Public IP address you should ask for the IP provider company. Without a public address, the client side app couldn't access your application from internet.
If your web api and the client app are in the same intranet, you could let the client app directly access the web api after the web api hosted on IIS by using hosting server's IP address.
About how to host the asp.net core application on IIS, you could refer to this article.

Related

How can I access web api though my Wi-Fi?

I am building a .net 7.0 core minimal web api in VS2022 and would like to be able to access the swagger index.html page outside localhost, for example from my iPhone over my home network.
I have tried adding my home ip address to the urls in launch settings.json to no avail and worked through various links such as configuring kestrel endpoints, Rick Strahl’s post on exterior kestrel endpoints, but still not able to connect outside local host!
I have tried running the application in both iis express and https debug settings.
You can use services like ngrock.
Check out this answer.

Command remote machine from blazor PWA

I have a blazor wasm PWA with asp net 6 web Api as backend hosted in IIS (win server 2012r2). Now I need from blazor PWA to command some phisycal machine at different customer locations. From the App user need to show the current state of a single machine and modify machine parameters. So the App do the request for current machine settings, the machine responds with data, and the app can modify and save the settings to the machine. The PWA must be able to communicate with one machine at a time choice from a list. So the PWA communicate with Api and Api need to have a bidirectional communication with the client machine. Is this the correct way? Which technology is suitable for this purpose? Signal R (between the server and the machine)? Than you

Simple hosting of a .NET Core Web API Service (Similar to NodeJs)

I have a .Net Nuget Package that works on a .NET Core Web API Service when it is proxied by my API Management Server. I would like to setup some automated testing of this service to be run when I run my builds.
Normally, when I want to run a service to be seen from other computers, I host it in IIS. But I would rather not have to have IIS up and running on my build servers.
I am wondering, is there a simple way to host a .Net Core Web API Service that can just run in-memory? (Similar to the way NodeJs can be run) I understand that Kestrel is used under the hood for ASP.NET Core. Maybe it be setup to do that?
NOTE: Because this will be proxied by my API Management Server, it need to be accessible by other servers on my network. (Not just localhost.)
Kestrel is the simplest way you can use to achieve, you can config kestrel to enable it listening to remote request, see this document

ASP.NET Core 3 Web Is Not Able To Connect ASP.Net Core 3 Web API on same server

I have a web application that has built on ASP.NET CORE 3. This web application uses asp.net core 3 web api. Everything works fine. But problem starts when I move them to the staging server. Web Application was not able to connect web api. They both hosted on same machine but have different port.
For example :
Web Application URL http://52.X.X.X:94/MyWeb
Web API URL http://52.X.X.X:91/MyWebAPI
I get following error
System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have enabled CORS in web API.
However, If I move Web Api to Port 80 (http://52.X.X.X:80/MyWebApi ) then everything is working.
On my local IIS they both are working.On local IIS they were published on same port ( 94 and 91 respectively)
Can anyone tell what I am missing?
do you have appropriate web.config on server? compare local web.config with server web.config. maybe you missed some part like kestler or something else.
if it's alright, then check your webapi with postman, maybe webapi didn't published correctly.

Authentication against Active Directory using a Mobile Device

I currently have a Mobile Application that communicates through a WCF Service to access a Database. The Mobile App can access on the network as well as externally. It connects to the WCF Service which is hosted on one server inside the network. From there the WCF Service is pointing at another server which is hosting the Database that the Mobile Device is accessing.
With the above process how would you setup authentication using Active Directory which would confirm the user of the Mobile Application before it can access the WCF Service to confirm that the user is a member of AD and they can then login after authorization is complete. This would occur as the user opens up the Application. Would this be coded into the App to prompt for the information, then send the information to the WCF Service which would then allow access? If not this then are there any other ways or information/links that can be provided please?
Take a look at the BUILD 2013 videos. Visual Studio 2013 will create a webproject that will automagically do all that for you (I think). Just bare in mind, it uses the Microsoft.OWin.Security beta packages.
Also...you will need to install the AspNetWebTools2013 package first...
http://www.asp.net/visual-studio/overview/2013/creating-web-projects-in-visual-studio#orgauthoptions