Publish WebApi to Subfolder Publish WebApi to Subfolder asp.net asp.net

Publish WebApi to Subfolder


See this answer

Use the Visual Studio "Web Deploy" publish method.

Set "Site name" tolocalhost/api instead of localhost


After going through each folder, I noticed one folder that I did not check - Providers. And in there is a class called ApplicationOAuthProviders.cs. Once I changed values in that file, social logins started to redirect correctly.

There are a number of changes that need to change to publish to a subfolder; they are:

  • ApplicationOAuthProvider: context.Request.Uri, "/YourSubfolder/"
  • app.datamodel.js: self.userInfoUrl = "YourSubfolder/me"; (remove first slash)
  • app.viewmodel.js : window.location = "/YourSubfolder/Account/Authorize?client_id=web&response_type=token&state=" + encodeURIComponent(window.location.hash);
  • WebApiConfig.cs: routeTemplate: "YourSubfolder/{controller}/{id}"


Have you tried adding virtual directory in your IIS website?
I have my API as separate project and I can refer to it by using www.your-web-site/API-subfolder

To do it go to your IIS -> context menu on your website. Then:
enter image description here
And add alias (subfolder-name) and Physical path to your API project.
It should work