How to Deploy ASP.NET Core Web API on IIS Windows Server || Deploy ASP.NET Web API on IIS .NET 7.0

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to macro code if you're new to this channel consider subscribing so today we are going to learn how to deploy asp.net web API on is a web server so I'm going to deploy uh these rest API so we actually created this recipe on our previous video so if you don't know how to do that please watch on our previous video and I'll paste down below the link so that you you are able to catch up with this video so on this API we have the students controller which actually performs all the operation that is the get put post and delete then we have our model for students these are the data that you are supplying then we have a program.cs so we are using SQL Server so and the app settings we have a connection to the database so if we I just launched this app you're able to see our rest API there you are you can see we have this API we are calling it rest sample we have the get endpoint then we have the post endpoint we have the students get by ID then the puts and the delete so if we try to run this try it then you execute you should be able to get uh some records you can see we have some records so we are going to see how to deploy this API so what you need to do will right click on our project here then we are going to publish so if you right click then choose publish there you are so the targets we are going to Target it to a folder you can also Target it to uh Azure Docker container registry FTP web server or import file so I'm going to publish our files to a folder so I'll just choose folder then next then I'm going to choose the location so I'll just choose my desktop then I'll create a new folder in my desktop called published then okay let me try again we need to choose this one yeah so you can see published then finish so it will actually you can see we have our Target location delete existing file we can actually edit this so that we can in case there are files that exist we can delete them so if you click on edit you can see we contact we can run this as portable uh we can Target portable Windows uh 64 bits uh 32-bit uh RM machine 64. so you can actually deploy this depending on that so for me I'm going to choose let me choose Windows uh or you can leave it as portable then uh file publish options delete existing files prior to published check that then the database you can see we have already a connection that we had on our app settings.json then Entity Framework you can see you already have the connection to our database so we'll save this so this should now change to True Target a framework is.net7 then Target runtime is portable so after you have done that at the top right corner you'll see a publish icon so click that then a projection publish so it's publishing so we are deploying these to our Ias so if you're new to this channel consider subscribing and if you're already watching our videos and you have not subscribed you are not doing good to us please just subscribe so let's open our desktop so you can see on our folder we have the files already published you can see we have these already published so what we need to do we need to open our eyes so click on Windows then just search is so I'm deploying this to my local machine so I'll open is so this internet information service manager then under is I'm going to create application pool you can see so I'll create add application to pull on my right hand side then I'm going to say dot net press API then I'll just leave it the rest as it is then I click ok then under sites you can see I'm going to create a new site so I'll add a site then I can select the pool you can see I can select the pool that I want to use so I'll select that pool then okay then the site name I'm going to call it sample rest fpi then what I need to do with my files I'll copy these files then go to local disk C then uh inet Pub go to inet Pub then window ww root folder then under ww root folder I'm going to create another folder then I'll call it a rest API then under the rest API now I will paste my files so I'll press my files there foreign so there you are we have our files so back to our eyes so under the content directory physical path I'll choose the I'll try to select the files now under local disk C inet Pub then www root then rest API the folder that you have just created so I'll select that then I leave it as it is then the pot I can have a I can indicate the port that I want my application to be running then I leave this as all an unassigned then I can have it as HTTP but in case you want to bind it to an SSL certificate then you will choose https then it will give you other options then you will select the SSL certificate that you want to uh use this is after installing remember so for now I'm going to use HTTP so in case you want us to demonstrate us comment down below so that we'll be able to show you guys so I'll try to test the settings to see if everything is okay I can see everything is working fine so I'll click ok so you can see we have now our rest API or as one of our sites under the sites a folder on this other side you'll see it is running on Port 2013. and everything is fine so in case you need to do any changes after you have done the settings you can actually use the basic settings then you can change the location but in case you want to change the ports and the SSL then you will do bindings then you can see you can also edit and you can still go through the same same process so everything should be now fine so what we need to do is to browse these applications so let's browse to see if it will run so you can see it is local loss 2030. so application you can see it is saying this localhost paid can't be found the fpi is telling us this local page can't be found so really what you need to test you as you can see on our API we have the weather forecast controller and we have the students controller so we can try to access the weather forecast controller by typing the controller name on our page so you can do slash then weather forecast we see if it will return some data so you can see it has actually returned the data so our API is actually working but now when we try to access Swagger you can see we are not able to go through that so in a speed.net.com uh currently Swagger is only allowed on development amount so you can see these can only be used in development mode which is actually the correct thing to do but in case you want to access this um even after deployment then you can remove these outside there you can actually add it also maybe just add it outside this code under the program.cs file so you can also try to redeploy that you can see if we can access Swagger so I'll deploy that so it's done so I'll also go back to desktop then copy my files then take them to Local DC I net Pub then www then I request it again so I'm replacing you I can stop my API under is we'll try to foreign copy the code so these are the published files so trying to copy them back to inet Pub www then so I'll replace them so go back to is I can restart my app then go to so if I try to refresh this now I should be able to see Swagger you can see Swagger is now up so you can actually enable Swagger on the deployment by uh adding this code down here or which is actually not is not a good practice so you should only be accessing that under development so if you want to access them when you deploy your app then you can add the code outside the user if statement so that is it guys so we have deployed our API and uh and uh and we have deployed our API in is and you can see everything works well so that is it guys so we cannot now access our app under is so if you have any question comment down below and see you in our next video bye foreign
Info
Channel: Macro Code
Views: 55,131
Rating: undefined out of 5
Keywords: AmigosCode, .NETCORE, Sundeep, Saradhi, freecodeCamp, ProgrammingWithMosh, MikeDane, IamTimCorey, TeddySmith, FireShip, DaniKrossing, Stefan Mischook, ASP.NET CORE, Coder Foundry, Jose Montemagno, .NET 7, Nick, Nickchapsas, Jake Wright, Keep On Coding, QuestPond, Amigos, Developer Filip, TechWorld With Nana, Techworld, GotoConferences, CRUD, ASP.NETCORE, SQL, SERVER, BoostMyTool, API, AUTHENTICATION, JSONWEBTOKEN, Code with Julian, MinimalAPI, POSTMAN, FLAVOUR, BroCode, CodeWithBen, Deploy, IIS, Windows IIS, dotnet
Id: kMmZ9SbPBQA
Channel Id: undefined
Length: 12min 1sec (721 seconds)
Published: Sat Apr 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.