but when I run the application it throws an error :
Line 27: Line 28: ' Code that runs on application startup
Line 29: GlobalConfiguration.Configuration(AddressOf AppStart.WebApiConfig.Register) Line 30:
''GlobalConfiguration.Configuration(Register)
output :
Microsoft (R) Visual Basic Compiler version 14.8.3761 for Visual Basic 2012 Copyright (c) Microsoft Corporation. All rights reserved.
This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to Visual Basic 2012, which is no longer the latest version. For compilers that support newer versions of the Visual Basic programming language, see http://go.microsoft.com/fwlink/?LinkID=533241
C:project\webapp\global.asax(29) : error BC30545: Property access must assign to the property or use its value.
GlobalConfiguration.Configuration(AddressOf AppStart.WebApiConfig.Register)
I've downloaded all the packages from nuget:
global.asax
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
GlobalConfiguration.Configuration(AddressOf AppStart.WebApiConfig.Register)
End Sub
webapiconfig class
Imports System.Web.Http
Namespace AppStart
Public Class WebApiConfig
Public Shared Sub Register(configuration As HttpConfiguration)
'// Web API routes
configuration.MapHttpAttributeRoutes()
configuration.
Routes.
MapHttpRoute(
"API Default",
"webapi/{controller}/{id}",
New With {Key .id = RouteParameter.Optional}
)
End Sub
End Class
End Namespace
webconfig
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<!--webapi-->
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<!-- end web api -->
</handlers>
<system.webServer>
The only thing I did was to update the web.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
by removing xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
It looks like this line led to this error:
Microsoft (R) Visual Basic Compiler version 14.8.3761
for Visual Basic 2012 Copyright (c) Microsoft Corporation.
All rights reserved.
which is no longer the latest version.
For compilers that support newer versions of the Visual Basic programming language, see