Reputation: 41
I already have a web application in the root folder of my website. (e.g. http://cassapi.gear.host). Now I want to add one MVC web API application in a subfolder inside the 'wwwroot
' folder, so that I can access my home controller something like "http://cassapi.gear.host/DOTAPI/api/values" without troubling the website in the 'wwwroot
' folder.
Note: It's working fine when I publish this MVC application in the root folder.
My web.config is like this :-
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
My root config:-
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "DOTAPI/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
i am a windows application developer and new in MVC. so, please look into this and help me.
Currently , when i am calling the url "http://cassapi.gear.host/DOTAPI/" it shows "You do not have permission to view this directory or page."
Upvotes: 4
Views: 2143
Reputation: 107
If you are getting a access denied error, then you must give permissions to iis_users
group for your directory. And there is another way for achieving what you need. You can add your api
as an application to your main website. Below are the steps.
Add Application
.Then you can just browse your API with the alias you provided.
Upvotes: 4