1

I need to use Microsoft.AspNet.WebApi.Versioning in VB.NET but I cannot translate the following code:

config.AddApiVersioning(o =>
{
   o.AssumeDefaultVersionWhenUnspecified = true;
   o.DefaultApiVersion = new Microsoft.Web.Http.ApiVersion(1, 0);
});

var constraintResolver = new DefaultInlineConstraintResolver()
{
   ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) }
};
config.MapHttpAttributeRoutes(constraintResolver);

In particular I have an error when I define DefaultInlineConstraintResolver:

Dim constraintResolver = New DefaultInlineConstraintResolver() With
{
   .ConstraintMap = { ["apiVersion"] = GetType(ApiVersionRouteConstraint) }
}

How resolve? Tks.

0

1 Answer 1

1

I have found the solution. The correct code is:

Dim constraintResolver = New DefaultInlineConstraintResolver() 
constraintResolver.ConstraintMap.Add("apiVersion", GetType(ApiVersionRouteConstraint))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.