0
votes

I am having this weird issue with VS 2015 Update 3 while running Web API project via IIS Express. Here are the steps I followed

1> Start Visual Studio 2015 (with Update 3)
2> Select new Asp.NET 4.6.2 web project
3> Select Empty Project - > and check Web.API check box
4> Once the solution is ready then create new Controller using Web API2 Controller with read/write actions and name the controller DocumentController
5>The routeTemplate is set as routeTemplate: "api/{controller}/{id}" at project startup.
6> Press F5 to run the application
7> Visual studio host the API in IIS express as http://localhost:53394 so I type http://localhost:53394/api/document and I see some json result in the browser as expected.
8> Now i change API project's project URL from http://localhost:53394 to http://localhost:53394/api/document hoping I don't have to type whole url everytime. When I change the URL I get prompt

enter image description here

I select yes. However that doesn't work. In-fact now my URL becomes http://localhost:53394/api/document/api/document

9> So I change the project URL back to what it was http://localhost:53394. This time it didn't prompt me.

10>Now when I try to access the api usinghttp://localhost:53394/api/document I get error

HTTP Error 403.14 - Forbidden

The Web server is configured to not list the contents of this directory

but if I access api using URL http://localhost:53394/api/document/api/document then I get result back.

I have tried restarting visual studio, clearing browsers history with no luck Not sure why & where VS caching URL.

1

1 Answers

0
votes

Visual Studio isn't caching any URL.

Change your project settings' url back to http://localhost:53394/. This is the root url of the website.

Next, you'll need to clean up your IIS Express configs. You can mess around with the XML if you're up for it. I find it best to just delete the folders. VS will recreate them anyways.

These configs are located in a special folder named .vs that's in the same folder as your solution file. It's hidden, so you'll need to Show hidden files in Windows Explorer. (Note to any other readers, this is specific to VS 2015. In earlier version of VS, these configs are in an IIS Express folder in AppData.)

After this, you should recreate the virtual directory, and try again. Update your question with the results if this doesn't work.