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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:28:38+00:00 2026-06-09T17:28:38+00:00

I have read a few articles detailing how to use JSONP with MVC4 (i

  • 0

I have read a few articles detailing how to use JSONP with MVC4 (i am using the RC version) and the new Web Api. I am trying to perform a cross-domain request.I have no idea what I am doing wrong. My controller is inheriting from the ApiController class in MVC4. I tried Rick Strahl’s implementation and a few others. Here is my example method:

public string StartTracking(string apiKey, DomainTracking domainTracking)
        {
            var user = _userService.GetByApiKey(apiKey);
            if(user != null)
            {
                var domain = user.Domains.FirstOrDefault(d => d.Name.ToLower() == domainTracking.Domain.Name.ToLower());

                if(domain != null)
                {
                    domainTracking.DomainId = domain.Id;
                    domainTracking.Domain = domain;

                    domainTracking.CreatedById = user.Id;
                    domainTracking.ModifiedById = user.Id;

                    var newDomainTracking = _domainTrackingService.Create(domainTracking);
                    return newDomainTracking.Id.ToString();
                }
            }
            else
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
        }

Here is my Jquery request code:

function getSessionKey() {

    var Domain = { 'Name': domainName };
    var DomainTracking = { 'Domain': Domain, 'FormElements': getFormElements(), 'ClientLocation': clientLocation };


    $.ajax({
        url: 'http://api.testdomain.com:4646/api/' + apiKey,
        type: 'GET',
        cache: false,
        timeout: 100000,
        data:  DomainTracking,
        dataType: "jsonp",
        error: function (xhr, status, error) {

        },
        success: function (data) {
            sessionKey =  data;
        }

    });
}

If I change the method name to GetStartTracking is receive a 500 error. If I leave the name StartTracking I get a 405 not allowed error. What do I need to do?

  • 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-09T17:28:40+00:00Added an answer on June 9, 2026 at 5:28 pm

    Try using the “Get” as the name of your method. JSONP might not work with posts, so your data will all have to be in the url, I don’t think you can use the data attribute of the ajax function.

    This may help

    public class TrackingController : ApiController
    {

    …
    public string Get(string apiKey, string Domain, string FormElements, string ClientLocation)
    {

    //do everything here

    }

    }

    and the URL of the request should contain the name of your Controller and all information in the url. There might be other ways to do it, but this should work.

    http://api.testdomain.com:4646/api/Tracking/?apiKey=something&Domain=abc&FormElements=1,2,3&ClientLocaiton=somewhere

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

Sidebar

Related Questions

I have read a few articles, I can't see why one would use html5
I'm fairly new to DDD and have read a few articles about the concept
I've read a few articles on here and the web that have informed me
I have read few articles about table partioning but still I am bit confused
I'm fairly new to working with relational databases, but have read a few books
I have read a few articles on Internet about programming language choice in the
I'm trying to use copy'n paste in one of my web apps and have
I have asked a few questions on here and read a few articles around
In the past few years I have read plenty of articles on Foreign Keys
Hey there, I have read the few posts here on when/how to use the

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.