我在将此转换为vb.net时遇到问题
c#
global.asax
protected void Application_BeginRequest()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
public static void Register(HttpConfiguration config)
{
config.Routes.Clear();
}
vb.net
Protected Sub Application_BeginRequest()
GlobalConfiguration.Configure(WebApiConfig.Register)
End Sub
Shared Function Register() As Action(Of HttpConfiguration)
End Function
我在注册方法的vb.net版本中遇到问题。如何像在c#中一样访问HttpConfiguration的参数。
答案 0 :(得分:6)
您必须使用AddressOf
运算符:
Protected Sub Application_BeginRequest()
GlobalConfiguration.Configure(AddressOf WebApiConfig.Register)
End Sub
Public Shared Sub Register(config As HttpConfiguration)
config.Routes.Clear()
End Sub