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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:31:38+00:00 2026-06-17T05:31:38+00:00

I am trying to load data from a web-api controller from within a razor

  • 0

I am trying to load data from a web-api controller from within a razor page that was loaded by a standard controller.

However, when I try to execute the $.getJSON() it fails because the getJSON method adds its original controller name in front of the call. How do I go around this?

Example: a razor view gets loaded from controller MyController. I have a webapi controller called ExplorerApi where I wish to execute a method on.
So from within the razor View I call

$.getJSON("api/explorerapi/getavailablegroups?userid=marcel", function (data))

which fails because jQuery has added MyController in front and so converted it to:

$.getJSON("MyController/api/explorerapi/getavailablegroups?userid=marcel", function (data))

EDIT –

I can call the web api from the browser and it happily returns the json data by simply typing http://localhost:59475/api/ExplorerApi/getavailablegroups?userid=marcel&context=pf in the browser!
but using the code below it adds it originating controller name in front!

var uID = sessionStorage.getItem("symUserID");

            var v = "userid=" + uID + "&context=portfolio";
            $.getJSON("api/explorerapi/GetAvailableGroups?" + v, null, function (data) {
                debugger;
            })
            .fail(
            function (jqXHR, textStatus, err) {
                debugger;
                alert(err);
            });

The alert message says: Not found – then if you look into the jqXHR.responseText loads of data there is the Error 404 and further down the statement it is trying to execute in which it has placed the name of the original controller!!

Requested URL   http://localhost:59475/MyController/api/explorerapi/GetAvailableGroups?userid=marcel&context=portfolio&_=1358064733267

  • 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-17T05:31:40+00:00Added an answer on June 17, 2026 at 5:31 am

    Instead of “api/explorerapi/GetAvailableGroups?” use “/api/explorerapi/GetAvailableGroups?”.

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

Sidebar

Related Questions

I am trying to load data from a JSON web service and display it
I am trying to get data from web services from my app to load
I'm trying to parse data from the web, basically, from an API (Google Finance
I'm facing a rather strange Issue when trying to load data from an XML-Webservice.
I am trying to load mysql data from my database from a html select
I'm trying to load and parse json data from an external source into a
I'm trying to perform the acquisition of data from the internet on the load
I am trying to re-load a table every time some data I get from
I'm trying to load test a web service. I've got a simple method that
I'm trying to integrate weather data from the NOAA in my web site, and

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.