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 8292767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:35:32+00:00 2026-06-08T13:35:32+00:00

I have the following simple jquery get statement that calls a WebApi on my

  • 0

I have the following simple jquery get statement that calls a WebApi on my server:

$.get('api/DataAPI?tenantId=1&datatype="Contacts"&actionname="ActiveOnly"', GetDataRetrieved);

This works fine in visual studio. I checked the network traffic in chrome and it shows the following request created:

http://localhost:61882/api/DataAPI?tenantId=1&datatype=%22Contacts%22&actionname=%22ActiveOnly%22

I have now deployed my website to IIS and the api call now fails with a 404 not found. I checked the network traffic in chrome and can see the problem:

http://localhost/api/DataAPI?tenantId=1&datatype=%22Contacts%22&actionname=%22ActiveOnly%22

Where the website when deployed to IIS is located at http://localhost/MyWebSite. So the call should go to:

http://localhost/MyWebSite/api/DataAPI?tenantId=1&datatype=%22Contacts%22&actionname=%22ActiveOnly%22

What is the correct syntax in my $.get call so that it works for both visual studio and deployed to IIS (I would love to use razor @Url.Content but that doesnt work in the javascript block)?

Thanks in advance

edit: This is the markup for the entire .cshtml page:

@{
ViewBag.Title = "MyWebSite";
Layout = "~/Views/Shared/SiteLayout.cshtml";
}

@section HeaderContent
{
<script type="text/javascript" src="@Url.Content("~/assets/scripts/App/Base64EncodeDecode.js")"></script>
 }

<script type="text/javascript">   
    $(function () {               
    $("#TestButton").click(function () {            
        $.get('api/DataAPI?tenantId=1&datatype="Contacts"&actionname="ActiveOnly"', GetDataRetrieved);
    });
});

function GetDataRetrieved(data) {        
     //alert(base64_decode(data));
    alert(data);
}   
</script>

<button id="TestButton">Test Button</button>
  • 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-06-08T13:35:32+00:00Added an answer on June 8, 2026 at 1:35 pm

    Assuming that your Javascript is located directly on the page:

    $.get('@Url.Action("DataAPI", "API", new {tenantId = 1, datatype = "Contacts", actionname="ActiveOnly"})', GetDataRetrieved);
    

    should be what you need

    If it’s on another page, I like to associate the needed URL with the HTML element, and then use jQuery to extract it.

    <div id='foo' data-url='@Url.Action("DataAPI", "API")'>
    </div>
    

    and then your Javascript would look like:

    $.get($('#foo').data('url'), {tenantId: 1, datatype: "Contacts", actionname: "ActiveOnly"}, GetDataRetrieved);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple jquery snippet $(document).ready(function () { $.ajax({ url:myjson.json, dataType: 'json',
Very simple question: suppose I have the following js/jquery code doSomething(); $.get(url, callback); doSomethingElse();
I have the following simple jQuery: $.get('Data.csv', function(data) { alert(data); }); Data.csv is stored
I have the following problem: I am creating a simple plugin jquery carousel, to
I have a following simple code: def get(): return [lambda: i for i in
I have the following jQuery: // get position on new/removed items function get_new_position_for_all_items() {
I have a simple PHP page (for testing) that simply calls header(Location: http://www.example.com );exit;
I have a simple jquery loop that goes through my form and sees if
I am at a loss here with some simple jQuery. I have the following
I have a simple jQuery AJAX funciton: $.ajax({ type: GET, url: json/ + address,

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.