user1625066
user1625066

Reputation:

Visual studio - Separate asp.net projects

I'd like to start a new website and build it out as two separate projects under the same visual studio solution. One project will be used for the website and the other project will be used as an API.

  1. UI (MVC 4 project)
  2. API (WebAPI project)

I have the "UI" project setup as the startup project with project URL http://localhost:49770/ and the "API" project setup with project URL "http://localhost:49770/API/". The project compiles and runs correctly but requests to http://localhost:49770/API/ are getting trapped by the UI project and displaying a 404 error. How can I configure the UI project to stop trapping requests to the API project?

Edit: I figured out that the WebAPI project is accessible at http://localhost:49770/API/API/. Is there a way to get it to be accessible at http://localhost:49770/API/?

Upvotes: 0

Views: 514

Answers (2)

user1625066
user1625066

Reputation:

Figured it out on my own. Here are the steps if anyone is interested

  1. Create a MVC 4 project called UI and set its project URL to be http://localhost:49770/
  2. Create a WebAPI project called API and set its project URL to be http://localhost:49770/API
  3. Edit the webapiconfig.cs file under API\App_Start and change the default route from "api/{controller}/{id}" to "{controller}/{id}".
  4. Set the UI project to be the startup project.

Now, your MVC project will be accessible at http://localhost:49770/ and your API will be accessible at http://localhost:49770/API/

Upvotes: 1

Vilx-
Vilx-

Reputation: 107002

One way to do this is to use full IIS, not the Express edition.

Upvotes: 0

Related Questions