I am attempting to troubleshoot a simple call to a controller method from some javascript in an ASP.NET web application. In all cases, I am getting a 500 internal server error response from the test server, but the code works fine on my localhost when running from Visual Studio. Of note is that on the test server, the application is not deployed at the server’s root but at ./apps/testApp.
Client side code:
var strMethodUrl = "./Opportunities/DummyData";
$.getJSON(strMethodUrl, function (data) {
opportunities = data;
callback(opportunities);
})
// Using jQuery interface as of v1.8 (https://api.jquery.com/jquery.getjson/)
.done(function() {
var debugString = "getOpportunitiesData:$.getJSON.done";
console.log(debugString);
alert(debugString);
})
.fail(function() {
var debugString = "getOpportunitiesData:$.getJSON.fail";
console.log(debugString);
alert(debugString);
})
.always(function() {
var debugString = "getOpportunitiesData:$.getJSON.always";
console.log(debugString);
alert(debugString);
});~
Controller code is located in the Visual Studio 2013 project’s Controller subdirectory and is named OpportunitiesConroller.cs. It contains this dummy t/sing method:
// GET: Opportunties
public ActionResult DummyData()
{
var opportunities = new List<OpportunityModel>();
var opportunity = new OpportunityModel() { AdvertisementID = "ID_TEST", RankRange = "RANK_TEST", QualificationSummary = "QUAL_TEST", MissionName = "MISSION_TEST", ReportDate = DateTime.Now, EndDate = DateTime.Now, Location = "LOCATION_TEST" };
opportunities.Add(opportunity);
return this.Json(opportunities, JsonRequestBehavior.AllowGet);
}
Add here is the registering of routes:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("");
routes.MapRoute(
name: "Default",
url: "apps/testApp/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
As mentioned above, this all works on a local development machine when running from VS2013. The project is then deployed to www.TESTSERVER.com/apps/testApp.
When one navigates to the page that executed the javascript above, the browser’s debugger shows the 500 error for the dynamic request (https://www.TESTSERVER.com/apps/testApp/Opportunities/DummyData). And when I enter https://www.TESTSERVER.com/apps/testApp/Opportunities/DummyData directly into my browser it also outputs an error page: Server Error in '/apps/testApp' Application.
UPDATE: Thanks to some awesome advice, we were able to enable remote server error info, and it turned out all of the above was a red herring to the real issue. Have not had a chance to resolve the issue, but here is what the error info is:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'testApp.Api.MvcApplication'.
Source Error:
Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="testApp.Api.MvcApplication" Language="C#" %>
Source File: /apps/testApp/global.asax Line: 1
Any thoughts?
Thanks