0

guys! I have an issue.

  1. I created .net core webapi project in vscode using terminal.

  2. Made following commands: dotnet restore, dotnet build, dotnet run.

  3. Unfortunately, project does not run. But When I run it in visual studio, it works.

I do not know where I am doing wrong enter image description here

4
  • Because you haven't call associated view on your route. Your back-end is up and running. Just call a view Commented Mar 10, 2020 at 13:37
  • When it "works" in Visual Studio, what URL are you invoking? In your code, what response do you expect from the root URL? Commented Mar 10, 2020 at 13:41
  • 1
    Try to browse to localhost:5003/weatherforecast. Replace "weatherforecast" with whatever your controller is called (provided that you haven't changed the default route of course). Commented Mar 10, 2020 at 13:49
  • This is a Web Api project which is used to post and get data. It has no Views so you'll not be able to see any page unless you include Views and associate them with the controllers. ! Commented Mar 10, 2020 at 14:23

2 Answers 2

2

Please go under the properties folder of your project, open the launchSettings.json and look for ApplicationUrl under Profiles. You will find the exact port your project is using.

Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't work for me.. even with swagger..
0

I faced the same problem today and came across this post. Web API (Dotnet Core) Project works from Visual Studio but not through Dotnet CLI. However, Web App (Dotnet Core) Project works from Visual Studio as well as through Dotnet CLI. (simply I am executing dotnet {webapp.dll} - without curley braces)

After a few trial-error as well as documentation from Microsoft I tried dotnet run "{dll}" and that works for me.
I have tried that for Web App + Web API (Dotnet Core) and both are working.

I know this is a very late reply but worth of adding my comments as it might worth of solving someone's problem, if not yours.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.