0

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

Mike
  • 777
  • 3
  • 7
  • 14
  • 1
    Well...are you **sure** it's a routing issue? 500 will collect almost everything went wrong server side. Btw do not hard-code url: use Url.Action() – Adriano Repetti Jul 30 '15 at 17:18
  • asp.net is new to me, so I was only guessing at the routing issue. With the controller method being so simple (and working when running from VS), I am not sure what part of the puzzle is the cause of the issue. – Mike Jul 30 '15 at 17:25
  • Let's do both: change to use Url.Action and enable remote errors – Adriano Repetti Jul 30 '15 at 17:26
  • Will change to Url.Action. On the suboptimal side, I have no direct access to the testserver (except for http) or any of its logs which might provide additional information. For the remote errors, is there anything that I can ask my server side colleague to look-at/provide-to-me? (total web app newbie question) – Mike Jul 30 '15 at 17:41
  • You need to [enable remote errors](http://stackoverflow.com/questions/2640526/detailed-500-error-message-asp-iis-7-5) for IIS through your web.config to see the underlying cause for a (non-detailed) 500 error. – Jasen Jul 30 '15 at 17:45
  • Regarding your second error, that type of message means either you are running the wrong .NET pipeline (version 2 vs version 4) as your app pool or your deployment didn't work correctly (missing some .dlls in your bin folder). Depending on your version of MVC, ensure your pipeline is set to "Integrated" pipeline and is set to thte correct version (most likely this should be the .NET version 4.x.xxxx option in IIS unless you are running MVC 1 or 2) – Tommy Jul 30 '15 at 18:13

0 Answers0