7
Answers

Failed to load resource: the server responded with a status

Alok

Alok

8y
442
1

I have a project that is developed using ASP.NET MVC architecture and SQL as database. The UI consists of .cshtml, and .javascript (.js) files and .cs files for the business logic and I am using Visual Studio as the IDE. I am facing a strange error when I run the code on my laptop. However the same code when executed and deployed on server runs perfectly fine without any errors.

Following is the flow of program:

1 Able to successfully login and connect to database (both locally and over the server)

2 A dashboard should be displayed which should retrieve records from database along with charts and graphs.

3 The Index.cstml file of the dashboard module calls a Dashboard controller which in turn calls few .cshtml files responsible for graphs, charts and records retrieval. These .cshtml files calls certain .js files which have methods for UI actions and related functionality.

The functionality works fine up to the point where dashboard controller is called with the dashboard page. There are no .js files as part of program flow till this point. The next call is as follows which calls the .cshtml file that is responsible for calling the .js files

return PartialView("_Request", rViewModel);

In this _Request.cshtml file there is path for the associated .js files which are not loaded.

<script src="/Scripts/Modules/Dashboard/request_methods.js?version=@DateTime.Now"></script>

<script src="/Scripts/Modules/Dashboard/request_events.js?version=@DateTime.Now"></script>

The dashboard hangs up without displaying any records or charts or graphs. I get the following errors when I right click on half loaded dashboard and say ‘inspect’ and then the following errors are displayed:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

http://localhost:50337/Scripts/generic.request_lock.js?version=7/28/2016%206:01:48%20PM Failed to load resource: the server responded with a status of 500 (Internal Server Error)

http://localhost:50337/Scripts/Modules/Dashboard/reportswidgets_methods.js?version=7/28/2016%206:01:48%20PM Failed to load resource: the server responded with a status of 500 (Internal Server Error)

http://localhost:50337/Scripts/Modules/Dashboard/reportswidgets_events.js?version=7/28/2016%206:01:48%20PM Failed to load resource: the server responded with a status of 500 (Internal Server Error)

The list continues for few more associated files .js files. A few more observations may help:

1. The same project when built locally and deployed on server is executed with records and graphs displayed on dashboard page.

2. All the .js files mentioned above and more are present at the location they are supposed to be locally.

3. IIS not used locally since using development version over the visual studio and directly connects to database.

4. The error occurs when connected to database both locally and over the server.

5. The same is observed for both IE and Chrome.

I have not been a developer on ASP.NET MVC earlier and request to help me out with this in really simple terms. Thanks in advance.

Answers (7)
0
Alok

Alok

NA 9 450 8y
<img src="/forums/uploadfile/e80988/355482/asp error.jpg" alt="" />I checked the network tab during inspect, which listed all the files executed during the run, along with the files that didn't execute. Upon clicking the errors the following was displayed, (check out the image), if this can help resolve the issue. Thanks.
0
Alok

Alok

NA 9 450 8y
Hi Vinay,
All permissions (full control, modify, read & execute, list folder contents, read, write) are granted over all the folders and sub folders of the project and for all the profiles (admin, system, my domain login account).
0
Vinay Singh

Vinay Singh

NA 5.9k 126.1k 8y
Ok
Then check the permition on the access script folder
0
Alok

Alok

NA 9 450 8y
Hi Vinay,
Thanks for the reply, however I am looking for a solution which does not involve changing the syntax of code. Actually, I am testing this application and get latest code from my development team. There are large number of files in the project and changing syntax of all them every time it is deployed isn't a feasible option. The point that the same code when deployed on server runs successfully but not on my local system is troubling me.
0
Vinay Singh

Vinay Singh

NA 5.9k 126.1k 8y
Hi
Try to add js file as given
  1. @sectionJavaScript
  2. {
  3. <scripttype="text/javascript"src="@Url.Content("/Scripts/SomeScript.js")"></script>
  4. <scripttype="text/javascript"src="@Url.Content("/Scripts/AnotherScript.js")"></script>
  5. }
http://stackoverflow.com/questions/33341143/how-to-load-external-javascript-file-in-mvc-5-layout-page
http://stackoverflow.com/questions/4311783/asp-net-mvc-3-razor-include-javascript-file-in-the-head-tag
http://stackoverflow.com/questions/24763493/how-to-include-js-files-in-the-view-asp-net-mvc-4
0
Alok

Alok

NA 9 450 8y
Hi Rajeev,
Thanks for the reply. I changed the path to relative with '~' symbol. Also there are many there are many .js files listed in error message whose path is relative and these are included in .cshtml files as said above . However, I didn't find any change in result and I still get the same error.
Also, adding another information, I have a certain older version of the code which runs perfect from my local system and has the same relative path mentioned for all the .js files. The new version of the code is the one giving problem. I compared a few relevant files and checked for difference if any but no luck. Please let me know if there is anything specific to be checked for difference. Thanks in advance.
0
Rajeev Punhani

Rajeev Punhani

NA 4.7k 402.7k 8y

Hi Alok ,

The issue is due to wrong path of js files.

  1. <scripttype="text/javascript"language="javascript"src="@Url.Content("~/Scripts/Modules/Dashboard/request_methods.js?version="+@DateTime.Now)"></script>
On server path will be something like

If the above solution is helpful then,accept the answer.