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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:15:10+00:00 2026-05-25T18:15:10+00:00

I am beginner for .net MVC. I guess my problem is related to route

  • 0

I am beginner for .net MVC. I guess my problem is related to route setting.

What I want to do is :I get data from database, in controller transfer data to json format and pass to view, use javascript decode json data and show on the html.

When I write methods under TechnologyController, type localhost:portnumber/Technology/Index, no decoded json data in html format, but if I type localhost:portnumber/Technology/GetJson
It show me a page with pure json data (which means if I call GetJson() method separately, it works)

I write the same code in HomeController, it runs correct, all the route setting is default:
routes.MapRoute(
“Default”, // Route name
“{controller}/{action}/{id}”, // URL with parameters
new { controller = “Home”, action = “Index”, id = UrlParameter.Optional } // Parameter defaults
);

//This is my controller

public class TechnologyController : Controller
{
public ActionResult Index()
{

return View();
}

public JsonResult GetJson() 
{

Technology myTech = new Technology(); //get data from database (Tested correct) 
return Json(myTech.select(), JsonRequestBehavior.AllowGet);

}
}

//This is Javascript:

<script type="text/javascript">

$(document).ready(function() {

$.getJSON("Technology/GetJson/", null, function(data) {

sss.innerHTML+=data["title"];// this part is correct (I already tested,please ignore), the purpose is to parse json data to html. 
.......
}
)};
)};

I understand if I call “localhost:portnumber/Technology/Index”, it only execute index method, that is why GetJson method is not called, but what url should I call in order to call index() as well as GetJson.

  • 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-25T18:15:11+00:00Added an answer on May 25, 2026 at 6:15 pm

    something like:

    $.getJSON("@Url.Action("GetJson","Technology"), null, function(data) {
    

    edit 2-

    Without Razor it would look like this:

    $.getJSON("<%= Url.Action("GetJson","Technology") %>, null, function(data) {
    

    Edit-

    Wait you want to call Index AND GetJson? That should already be happening, just load the /index page which calls index controller action, then in the rendered script from there your invoking the GJson action. Why would you think you need to call Index again?

    I imagine your method isnt getting hit because the url is incorrect. Grab fiddler*, and take a look at the acutal http traffic and see if it is 404’ing on the request.

    *(once fiddler is running change your url to http://localhost:port/….. to http://localhost.:port/…..)

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

Sidebar

Related Questions

As i am a beginner to asp.net-mvc which should i use ORM/ADO.NET data services....
I am a beginner in asp.net MVC. Importing table data using JSON, on column
I'm woondring how to insert data into my DataBase using Ajax in ASP.net MVC.
This is a beginner level question for asp.net MVC I have the following code
First of all i want to say that I'm still a beginner in ASP.NET
Which orm you would recommend for a beginner moving from ado.net?... Thus far used
I have a beginner level Json question with MVC.net (I've never really used jquery
I'm a beginner with C#, .net etc., and I am working with a MVC
I'm an absolute beginner with ASP.NET[MVC] so this is probably a dumb question. I
As I am a beginner to ASP.NET MVC, I would like to know what

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.