Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a problem after uploading the ASP Dot MVC Project on server. It works fine on local, but if I upload the build on server, Angular gives an error.

Using AngularJS v1.8.2, libraries are angular.js and angular-route.js.

I tried many solutions but they are not working. I don't know why it's happening on server. I just want to run my project properly.

Angular Controller Code looks like this:

JavaScript
angular.module('myAppOpd', ['ngRoute']).controller('OpCtrl', ['$scope', '$http', '$location', function ($scope, $http, $location) {    

    $scope.init = function ()
    {
        $scope.initNewPatientReg();
    }

    $scope.initNewPatientReg = function () {
        $http(
            {
                method: 'Get',
                url: '/Opd/GetNewReg',
                data: null
            }).then(function (response, status, headers, config) {
                if (response.status == 200) {
                    $scope.NewList = response.data;
                }
            }).catch(function (data, status, headers, config, $scope) {
                console.log($scope.message, 'Error!');
            });
    }

}]).config(function ($locationProvider) {

    $locationProvider.html5Mode(true);
});


And the view looks like this:

HTML
<div class="content" ng-app="myAppOpd" ng-controller="OpdDashboardCtrl" ng-init="init()">    
    
    <div class="row">
        <div class="col-md-6 col-sm-6 col-lg-6 col-xl-3">
            <div class="dash-widget">
                <div class="dash-widget-info text-right">
                    <h3>98</h3>
                </div>
            </div>
        </div>
        <div class="col-md-6 col-sm-6 col-lg-6 col-xl-3">
            <div class="dash-widget">
                <div class="dash-widget-info text-right">
                    <h3>{{NewPatientList.length}}</h3>
                </div>
            </div>
        </div>
</div>
</div>


and the error is when running the project on IIS.

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.8.2/$injector/modulerr?     


What I have tried:

I used many of things from Google, but still, my project does not work.
Posted
Updated 14-Sep-23 9:40am
v2
Comments
Richard Deeming 16-Aug-23 9:15am    
You haven't shown any of the code that brings in the Angular scripts, nor your scripts.

All the error message[^] tells us is that it failed to load a module due to "some exception". You've missed out the part of the message with the actual exception, so that doesn't help us.
Mansoordp 18-Aug-23 3:39am    
here base setup in _Layout.cshtml page with
<base href="/" />

and renderd the scripts in _Layout.cshtml page
@Scripts.Render("~/bundles/angular")
@Scripts.Render("~/bundles/Ngcontrollers")
Mansoordp 30-Sep-23 3:24am    
error is "Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.8.2/$injector/modulerr?p0=myAppReg&p1=Error%3A%20%5B%24injector%3Aunpr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.8.2%2F%24injector%2Funpr%3Fp0%3Dn%0A%20%20%20%20at%20http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A10%3A168%0A%20%20%20%20at%20http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A49%3A468%0A%20%20%20%20at%20d%20(http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A47%3A197)%0A%20%20%20%20at%20e%20(http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A47%3A438)%0A%20%20%20%20at%20Object.invoke%20(http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A48%3A16)%0A%20%20%20%20at%20d%20(http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A46%3A148)%0A%20%20%20%20at%20http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A46%3A287%0A%20%20%20%20at%20r%20(http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A11%3A76)%0A%20%20%20%20at%20g%20(http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A46%3A49)%0A%20%20%20%20at%20fb%20(http%3A%2F%2Fdev02%3A8080%2Fbundles%2Fangular%3Fv%3DWBZx8wk_-vJDZ3YonKXb00zJMs-JA9giQ01orZGP8zE1%3A50%3A153)"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900