Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7196231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:44:22+00:00 2026-05-28T20:44:22+00:00

I’ve created a scriptservice in my vb.net 4.0 web app (or web site… not

  • 0

I’ve created a scriptservice in my vb.net 4.0 web app (or web site… not sure which it is – does it matter?) because I want to call it from the client side. I get client errors saying my namespace is not recognized (HomepageService in the code below). I’ve tried qualifying it with the name configured on the project as “Root namespace”, but the js says it doesn’t recognize that namespace either.

The app is old – we recently converted it from dotnet 2.1 to 4.0.

I found the following related topic, because when I try to Import System.Web.Extensions in my HomepageServices.asmx.vb, visual studio says it doesn’t recognize the thing even though i can see it, listed right there in studio under References.

[System.Web.Extensions Assembly cannot be resolved][1]

I tried posting a followup question to that topic, becauxse I tried following the instructions in the answer but they didn’t work (I don’t have a “Target Framework” in Project > Properties > Application), but someone deleted it because I guess i’m not allowed to ask followup questions?

I’ve consulted various sites and followed instructions, here’s an example:
http://www.asp.net/ajax/documentation/live/tutorials/ConsumingWebServicesWithAJAXTutorial.aspx

Here is contents of HomepageService.asmx sitting in the root folder of my site:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Collections.Generic


<System.Web.Services.WebService(Namespace:="http://localhost/appname")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
<System.Web.Script.Services.ScriptService()> _
Public Class HomepageService
    Inherits System.Web.Services.WebService

    Shared _rand As Random = New Random(Environment.TickCount)

    <WebMethod()> _
    Public Function Test(ByVal s As String) As Integer
        Return _rand.Next(0, 120)

    End Function


End Class

Snippet from master page:

<body>
<form id="form1" runat="server">

    <asp:ScriptManager ID="Scriptmanager1" runat="server" EnablePageMethods="true">
        <Scripts>
            <asp:ScriptReference Path="CallWebServiceMethods.js" />
        </Scripts>

        <Services>
            <asp:ServiceReference Path="HomepageService.asmx" />
        </Services>
    </asp:ScriptManager>

and at the top of my page i import the js:

PageRequestManager.js:

HomepageService.set_defaultSucceededCallback(
                 OnLookupComplete);
HomepageService.set_defaultFailedCallback(
                 OnError);
function OnLookup() {
    HomepageService.Test(stb.value);
}
function OnLookupComplete(result, userContext) {
    // userContext contains symbol passed into method
    var res = document.getElementById("_resultLabel");
    res.innerHTML = userContext + " : <b>" + result + "</b>";
}
function OnError(result) {
    alert("Error: " + result.get_message());
}

My web.config is a mess, but I’ll be happy to post it…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:44:23+00:00Added an answer on May 28, 2026 at 8:44 pm

    Finally got it working. Here’s how I did it. Not sure what the problem was though.. but following the below process did the trick.

    Step 1. Follow the walkthrough at http://msdn.microsoft.com/en-us/library/bb532367(v=vs.90).aspx, using a new website project.
    It works. I’ll call this the model project.

    Step 2. Create files in my existing web app and copy all the code from the model project:
    – created WebService HelloWorld.asmx (studio also gives me a nested file, Helloworld.asmx.vb) in my project’s root folder. This is different from the model project, because when I created the webservice in that project, it put the .asmx in my root folder but it sticks the .asmx.vb in the App_Code folder. Not sure whether I should be moving it manually or something? In the past when I’ve tried to use App_Code or App_data folders with this web app, everything has gone to hell…

    Step 3. Edit the webservice to work with my web app instead of the website:
    – Namespace Samples.Aspnet commented out, not replaced with a different namespace since my app has a default namespace ‘Fubar’, which is the same as my app’s project name.

    Here is the resulting code in HelloWorld.asmx.vb in root folder of my web app:

    Imports System
    Imports System.Web
    Imports System.Collections
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    
    'Namespace Samples.Aspnet
    <WebService([Namespace]:="http://mycompany.org/"), _
    WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1), _
    System.Web.Script.Services.ScriptService()> _
    Public Class HelloWorld
        Inherits System.Web.Services.WebService
    
        Public Sub New()
    
        End Sub 'New
    
    
        'Uncomment the following line if using designed components 
        'InitializeComponent(); 
    
        <WebMethod()> _
        Public Function Greetings() As String
            Dim serverTime As String = _
                String.Format("Current date and time: {0}.", DateTime.Now)
            Dim greet As String = "Hello World. <br/>" + serverTime
            Return greet
    
        End Function 'Greetings
    End Class 'HelloWorld
    
    'End Namespace
    

    And here is the code in HelloWorld.asmx, also in the root folder:

    <%@ WebService Language="vb" CodeBehind="HelloWorld.asmx.vb" Class="Fubar.HelloWorld" %>
    

    Step 4. Create the js “HelloWorld.js”, stick it in root folder like it is in the model project, and paste the code from the model project. Make one edit to match my app’s namespace. Here’s the resulting code:

    var helloWorldProxy;
    
    // Initializes global and proxy default variables.
    function pageLoad() {
        // Instantiate the service proxy.
      //  helloWorldProxy = new Samples.Aspnet.HelloWorld();
        helloWorldProxy = new Fubar.HelloWorld();
        // Set the default call back functions.
        helloWorldProxy.set_defaultSucceededCallback(SucceededCallback);
        helloWorldProxy.set_defaultFailedCallback(FailedCallback);
    }
    
    
    // Processes the button click and calls
    // the service Greetings method.  
    function OnClickGreetings() {
        var greetings = helloWorldProxy.Greetings();
    }
    
    // Callback function that
    // processes the service return value.
    function SucceededCallback(result) {
        var RsltElem = document.getElementById("Results");
        RsltElem.innerHTML = result;
    }
    
    // Callback function invoked when a call to 
    // the  service methods fails.
    function FailedCallback(error, userContext, methodName) {
        if (error !== null) {
            var RsltElem = document.getElementById("Results");
    
            RsltElem.innerHTML = "An error occurred: " +
                error.get_message();
        }
    }
    
    if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
    

    Step 5. Add code to my ScriptManager tag in my master page. This corresponds to the model project’s code in Default.aspx;
    the ScriptManager tag below is identical to the one in the model project:

    <body>
        <form id="form1" runat="server">
    
            <asp:ScriptManager runat="server" ID="ScriptManager">
                <Services>
                    <asp:ServiceReference path="~/HelloWorld.asmx" />
                </Services>
                <Scripts>
                    <asp:ScriptReference Path="~/HelloWorld.js" />
                </Scripts>
            </asp:ScriptManager>
    

    Step 5. Add controls to my test page like they have in Default.aspx in the model project:

       <div id="divTestWebServices">
    
             <button id="Button1" onclick="OnClickGreetings(); return false;">Greetings</button>
             <div>
                <span id="Results"></span>
            </div>   
        </div>
    

    Step 6. Run Fubar and navigate to test page, then hit the button.

    It works!!! I don’t know why it wouldn’t work before, but after three days on this I’m ready to move on now …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.