Reputation: 5529
I need to port the following from the ASP.NET MVC 2 sourcecode from C# to VB.NET. It's from AuthorizeAttribute.cs beginning on line 86:
HttpCachePolicyBase cachePolicy = filterContext.HttpContext.Response.Cache;
cachePolicy.SetProxyMaxAge(new TimeSpan(0));
cachePolicy.AddValidationCallback(CacheValidateHandler, null /* data */);
where CacheValidateHandler is:
private void CacheValidateHandler(HttpContext context, object data,
ref HttpValidationStatus validationStatus) {
validationStatus = OnCacheAuthorization(new HttpContextWrapper(context));
}
The VB.NET port from http://converter.telerik.com doesn't quite work for this line:
cachePolicy.AddValidationCallback(CacheValidateHandler, Nothing) ' Error
where CacheValidateHandler is:
Private Sub CacheValidateHandler(ByVal context As HttpContext, ByVal data As Object, _
ByRef validationStatus As HttpValidationStatus)
validationStatus = OnCacheAuthorization(New HttpContextWrapper(context))
End Sub
VS2008 complains that CacheValidateHandler does not specify its arguments for context, data, and validationStatus.
Any ideas how to port this code?
Upvotes: 0
Views: 350
Reputation: 258
For passing functions as arguments in VB.NET, you have to use the AddressOf keyword:
cachePolicy.AddValidationCallback(AddressOf CacheValidateHandler, Nothing)
Upvotes: 3
Reputation: 115691
I think you need to use AddressOf
:
cachePolicy.AddValidationCallback(AddressOf CacheValidateHandler, Nothing)
Upvotes: 3