How to I run a C# Framework API - c#

The question may be a bit idiotic, but I can't find the answer on internet or Microsoft tutorials.
The goal of my project is to build an API to has to run locally on a Windows computer. My API mustn't have an interface or things like that, so I deleted every views and other files like bootstrap or jQuery. Then I call it with Unity.
The API works well, but I always run it with Visual Studio 2019. Is there something like a .exe or a command line to start my API ?
Thank you for your answers ! :)
PS : Yeah I know that an API running locally is quite useless, but with Unity it's really complicated to use things like pipes...

You can host your WebApi application in IIS, so you don't need to run it with Visual Studio.
If you are developing another project, you can ask Visual Studio to run multiple projects during a debugging session. While debuging your unity application, Visual Studio will run your API in the background:
https://learn.microsoft.com/en-us/visualstudio/ide/how-to-set-multiple-startup-projects?view=vs-2019
Otherwise, you may self host your asp.net webapi application.
There are official Microsoft tutorials on that:
For WebAPI 1:
https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/self-host-a-web-api
For WebAPI 2: https://learn.microsoft.com/en-us/aspnet/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

Related

ASP .NET Core 2.0 Deployment (code not executing)

I am very new to deploying applications to AWS, specifically Elastic Beanstalk through the "publish to AWS" feature built into visual studio 2017 after downloading the AWS toolkit.
My problem is that when I deploy my application which is a .NET core 2.0 empty application, it seems to deploy correctly (green health and no errors) and the "hello world" page is working when I navigate to the URL, but none of the functionality of the application is working.
I have a theory but I am not sure how to fix it.
When I run the code locally on visual studio 2017 everything works perfectly. When I deploy, I get no errors but code is not executed.
The application I made makes use of a main method which cascades all the other methods of the project, so I am assuming that my project is successfully deployed, but I don't have any commands, scripts or json files that states to start the main method.
How would you do that from visual studio/elastic beanstalk console?
Thanks for any help!

ASP.NET MVC Core Deployment via Visual Studio does not work

I am sorry to ask a question which doesn't have a specific problem, but I would be more than grateful if you could point the problem. (I can always provide other parts of my code which would be relevant to my question)
I am using Visual Studio to create my web application with ASP.NET MVC Core. All is good with the project and I can make it work on my localhost.
I bought a third party hosting service with Windows hosting (Plesk) and as far as I've asked them, they said their hosting plan supports ASP.NET Core.
For the deployment part, I've literally searched each and every source and tried various different methods but could not properly upload my files on ftp. Trying ASP.NET Core 1.0.0 version worked well and I uploaded a sample website, but since I am working with ASP.NET Core 1.1.0 now, I am unable to find a solution.
Here is what my publish profile looks like before hitting publish button:
I'm not really sure if I filled all the information correctly, but validation seems to work well.
And here is the log which I get after trying the publish via ftp method in visual studio:
Even though it seems to succeed, when I look at my ftp directory after this process, the files in visual studio project were never uploaded in the directory.
Any help is appreciated, thanks.
I have deploy the same on my server and it is working fine see the attached screenshot.

Code made on VS2017 for mac don't work on VS2017 for Windows

I'm not a developer but I needed to code a simple web page for a POC.
For that I used VS2017 for mac to make a MVC project and all is fine when I run it on "my machine" (yeah I know it a common issue :P), I mean I can build the solution and open the web page, this page is used to create/register an user at AWS Cognito.
But when I run this same solution in a windows machine with Visual Studio 2017, the project builds without errors the web page opens but I can't make the API calls to aws cognito, this machine has open access to internet, so it's not a network problem.
I think it can be a software problem, I'm using C# and .NET 4.5 + the AWS SDKs referent to the project.
Anyone has an idea?
Thanks in advance

Run a .net project on a system with IIS but no Visual Studio

I have a MVC 5 web application that is working fine. But due to internal security reasons and restrictions of my organization, I cannot host it as a website. My current requirement is to make this app run on a particular computer that has IIS installed on it but no Visual Studio.
My application makes use of MS-SQL database, Entity Framework, C# razors and all other .NET dependencies that are usual in a MVC app, and my target framework is 4.5.1 .
What I Found : I googled a lot, what I got is to create a Virtual Directory using the inetmgr and create the application under that directory. But since already the application is created I cannot go for this fix.
Please help me out by providing some links to refer to or steps to solve this.
Thanks in advance for any help.
What you will need to do is to either:
Use Visual Studio to publish the website directly onto the machine which is hosting the IIS application, as shown here.
Use Visual Studio an publish the application to a folder location on your machine and then use remote desktop or some other method to move the published DLL's to the virtual directory of the application.
Essentially both of them do the same thing, but sometimes due to security reasons, option 2 is easier to accomplish.

Why is my ASP.NET website not found by Visual Studio on a different computer?

I was working on a WCF service application in Visual Studio 2012 on my laptop while I was on the train. I'd much rather do work on my desktop so naturally, I zipped up the project files and transferred it over. The project contains the WCF service and an ASP.NET Web Forms Site. I've specified "Use Visual Studio Development Server" and assigned a static port to my project. Everything works on my laptop but for whatever reason, I get the following error when Visual Studio 2012 on my desktop tries to open my solution (specifically the ASP.NET Website Project).
http://localhost:5137 : error : Error opening web http://localhost:5137. The Web site 'http://localhost:5137' could not be found.
I'm not entirely sure what's going on here. The WCF service seems to be working just fine, but not the ASP.NET Website. What is the meaning of this error and how do I fix it? Also, how would I go about avoiding this in later projects? I'm sure not being able to move my work to other places is probably a problem.
I suspect this has something to do with whatever random port number "5137" was generated for the ASP.NET Website but I don't really know.
Thanks,
-Theo
have you tried the solution to open in VS and build again? may be you after compiling the code running it on your desktop machine via F5 or ctrl + F5 will run again the website.
I do face these random port number problems and what I do is restart :)
hope this help

Categories