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

  • SEARCH
  • Home
  • 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 4532240
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:00:18+00:00 2026-05-21T14:00:18+00:00

I have created a WCF REST style service in my project. In development I

  • 0

I have created a WCF REST style service in my project. In development I am able to specify the relative url to access my service,

 jQuery.ajax({
        url: "/WebServices/AddressWebService.svc/GetCountry",
        datatype: "json",
        success: function (data) {

            jQuery.each(data.GetCountryResult, function (index, value) {

                //value.entityData.CountryGuid
                //value.entityData.CountryName
                $('#dataCountry').empty();
                $('#dataCountry').append('<option value="' + value.entityData.CountryGuid + '">' + value.entityData.CountryName + '</option>');




            });

        }

    });

When I hosted to IIS (with port 81), with the root folder name c2c, I am no longer able to access the service

Using fire bug, I tried to see the headers, my relative url (“/WebServices/AddressWebService.svc/GetCountry) gets appended to my host (localhost:81) but the virtual folder name (c2c) is not getting appended. As a result it shows file not found exception

If I use the full qualified url (http://localhost:81/c2c/WebServices/AddressWebService.svc/GetCountry), it works fine.

If I am using full qualified url, It will be difficult to do changes when moving to production. Although we can use global variables to store the webroot (in this case c2c)

Are there any simple solution to solve this problem, I have also given the base address in the config file

<system.serviceModel>

         </binding>
     </webHttpBinding>
 </bindings>
 <services>
     <service name="c2c.WebServices.AddressWebService" behaviorConfiguration="jsonBehavior">

         <host>
             <baseAddresses>
                 <add baseAddress="http://localhost:81/c2c"/>
             </baseAddresses>
         </host>         

     <endpoint address="" binding="webHttpBinding" bindingConfiguration="webmax" contract="c2c.WebServices.IAddressWebService" behaviorConfiguration="jsonendpointBehavior" />

     <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
     </service>
 </services> 

  • 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-21T14:00:18+00:00Added an answer on May 21, 2026 at 2:00 pm

    You need to get a relative URL to the call to the ajax method. Typically what I do is

    $.ajax({ url: "<%=ResolveUrl("~/Services/Service.asmx/ServiceMethod") %>" });
    

    (obviously, you’d need the rest of the params to be set, and this would have to be on an ASP .NET control (like a page)).

    However, if you’re not spitting out the JavaScript on the page, that won’t work. In that case, you’ll want to pass in the URL of your web service to a JavaScript object or namespace, which is defined in the JavaScript include file. So you might have something like this:

    MyServiceMethodCaller.serviceUrl = "<%=ResolveUrl("~/Services/Service.asmx/ServiceMethod") %>";
    

    where you define the MyServiceMethodCaller namespace in your JavaScript include file. That way, inside your include file, you could have:

    var MyServiceMethodCaller = {
      serviceUrl: "",
      serviceMethod: function() {
        $.ajax({ url: this.serviceUrl });
      }
    }
    

    I think this should work. I haven’t brought it up in a tested, workable example, but you get the gist of it.

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

Sidebar

Related Questions

I have ASP MVC 3 application. I created WCF REST JSON Service and added
I have created a MVC 3 WCF Rest project using the tutorial described here
I created a new wcf rest service using .net 4. I have created a
I have a serializable dictionary that I created for a WCF REST web service
I have created a REST web service using WCF and use HTTP Post Method.
I have created a WCF REST Service and have successfully created a function to
I have created a WCF REST Search Service, and now want to know how
I have a WCF rest service. I created it using 4.0 rest service application,
I have created a WCF REST service that returns JSON, but the properties in
I have created a REST service using WCF for communicating with BLL/DAL from UI.

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.