'WebApi into a "IIS Application" causes 403.18 Forbidden error
This method works:
IIS > Sites > Add WebSite...
http://www.domain.com:<someport>/api/values
This doesn't:
IIS > Sites > SomeWebSite > Add Application...
http://www.domain.com/MyApplication/api/values
My WebApiConfig:
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute("DefaultApi", "api/{controller}");
config.Formatters.Remove(config.Formatters.XmlFormatter);
var jsonSettings = config.Formatters.JsonFormatter.SerializerSettings;
jsonSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
}
ValuesController:
[RoutePrefix("api/values")]
public class ValuesController : ApiController
{
[Route(""), HttpGet]
public IHttpActionResult Get()
{
return Ok("Is working");
}
}
I don't know the error reason, I've did a lot of research but I can't find what is causing this.
By the way, in the development environment the two ways works.
http://localhost:<someport>/api/values and
http://localhost/MyApplication/api/values
The server has the IIS 8.5.
The development environment has the IIS 10.
Any thoughts?
Solution 1:[1]
Issues to be checked to solve this-
1.check your operating system type[32 bit or 64 bit]. Because there may be mismatch occur between your development and deployment server
2.if 32 bit application running on 64 bit operating system or vice versa then error raised especially for webapi.So check it.
3.if deployment server only 64 bit then make your application application pool enable 32 bit applications- true from advance setting if your application develop in 32 bit otherwise it must be false
Solution 2:[2]
here is what was going on.
The IIS is configured to run PHP too. I have the Joomla installed on it.
After some investigation, a friend of mine detected some rules of URL Rewrite that were causing conflicts with the API.
The rules was modified and finally it's working now.
Thanks for you attention.
Solution 3:[3]
In my case, restart the PC to fix the problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LoopCoder |
| Solution 2 | Alexandre Perez |
| Solution 3 | Henry Lee |
