How to add WCF Web API with ASP.NET MVC 3 to existing VB.NET solution?
-
27-10-2019 - |
Question
Im trying to implement this code: http://wcf.codeplex.com/wikipage?title=Getting%20started:%20Building%20a%20simple%20web%20api and want to add it to my existing VB.NET solution.
But when I look at the source code I see a code behind file for global.asax (Global.asax.cs) file with a namespace defined in it?!?
Now in my existing VB.NET solution I DONT have a code behind file. Here's what my global.asax looks like:
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.HttpCookie" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.Security.Principal" %>
<%@ Import Namespace="System.Web.Security.FormsIdentity" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Resources" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="Microsoft.ApplicationServer.Http.Activation" %>
<%@ Import Namespace="System.ServiceModel.Activation" %>
<%@ Import Namespace="Microsoft.ApplicationServer.Http" %>
<%@ Import Namespace="ContactManager.APIs" %>
<script language="VB" runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("RM") = New ResourceManager("strings", Assembly.Load("strings"))
End Sub
</script>
When I add the namespace code as in the sample code I get: 'Namespace' statements can occur only at file or namespace level.
How can I implement the sample code correctly in my current solution?
Solution
You don't need to specify the namespace.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow