I have a custom controller config attribute created like the following:
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public class MyConfigAttribute : Attribute, IControllerConfiguration
{
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
{
controllerSettings.Formatters.Clear();
controllerSettings.Formatters.Add(new PlainTextFormatter());
}
}
My controllers are like the following:
-----------------------------------------
[MyConfig]
public class BaseApiController : ApiController
{
}
public class BugReproTestsController : BaseApiController
{
public string GetString()
{
return "Hello";
}
}
Request
---------
GET http://kirandesktop:9090/BugReproTests/GetString HTTP/1.1
Accept: application/xml
Host: kirandesktop:9090
Connection: Keep-Alive
Expected Response
---------------------
HTTP/1.1 200 OK
Content-Length: 82
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 17 May 2012 23:02:35 GMT
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Hello</string>
Actual Response
-------------------
HTTP/1.1 200 OK
Content-Length: 5
Content-Type: text/plain
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 17 May 2012 22:58:21 GMT
Hello
Problem
----------
Even though the MyConfigAttribute says "Inherited=false", the attribute is being applied to the sub-controller.
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public class MyConfigAttribute : Attribute, IControllerConfiguration
{
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
{
controllerSettings.Formatters.Clear();
controllerSettings.Formatters.Add(new PlainTextFormatter());
}
}
My controllers are like the following:
-----------------------------------------
[MyConfig]
public class BaseApiController : ApiController
{
}
public class BugReproTestsController : BaseApiController
{
public string GetString()
{
return "Hello";
}
}
Request
---------
GET http://kirandesktop:9090/BugReproTests/GetString HTTP/1.1
Accept: application/xml
Host: kirandesktop:9090
Connection: Keep-Alive
Expected Response
---------------------
HTTP/1.1 200 OK
Content-Length: 82
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 17 May 2012 23:02:35 GMT
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Hello</string>
Actual Response
-------------------
HTTP/1.1 200 OK
Content-Length: 5
Content-Type: text/plain
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 17 May 2012 22:58:21 GMT
Hello
Problem
----------
Even though the MyConfigAttribute says "Inherited=false", the attribute is being applied to the sub-controller.