Created
May 29, 2014 19:31
-
-
Save pranavkm/c0185df32933fb5b3ea6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Register(HttpConfiguration config) | |
{ | |
config.Services.Add(typeof(System.Web.Http.ValueProviders.ValueProviderFactory), | |
new EmptyValueProviderFactory()); | |
} | |
public class EmptyValueProvider : System.Web.Http.ValueProviders.IValueProvider | |
{ | |
public bool ContainsPrefix(string prefix) | |
{ | |
return prefix != null && prefix.Length == 0; | |
} | |
public System.Web.Http.ValueProviders.ValueProviderResult GetValue(string key) | |
{ | |
return null; | |
} | |
} | |
public class EmptyValueProviderFactory : System.Web.Http.ValueProviders.ValueProviderFactory, | |
System.Web.Http.ValueProviders.IUriValueProviderFactory | |
{ | |
private static readonly EmptyValueProvider _valueProvider = new EmptyValueProvider(); | |
public override System.Web.Http.ValueProviders.IValueProvider GetValueProvider(System.Web.Http.Controllers.HttpActionContext actionContext) | |
{ | |
if (actionContext.ControllerContext.RouteData.Values.Count == 0) | |
{ | |
return _valueProvider; | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment