Alex
Alex

Reputation: 549

How to create a REST API with .NET Framework?

I created a project in Visual Studio 2022 with the main template "ASP.NET Web Application (.NET Framework)" and sub template "Web API".

enter image description here enter image description here

This created a project with the ValuesController.

enter image description here

However, when I run the project and visit the url https://localhost:44342/api/values, I get the error:

This site can’t be reached

enter image description here

What do I have to do, to make this project work?

This is .NET Framework, not .NET Core, there is no launchSettings.json. The port is defined in the project file.

enter image description here

In the vbproj, there is this piece of xml:

  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>True</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>53888</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>https://localhost:44342/</IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>

Upvotes: 1

Views: 755

Answers (0)

Related Questions