Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change angularJS directive for IIS Default Web Site

I am creating a web application with ASP.NET MVC and AngularJS. When I debug the web application the URL is like this:

http://localhost/Home/Index#/Login

When I publish it to the IIS development server I use then I use the Default Web Site, so the url will be like this:

http://ipaddress/MyApp/Home/Index#/Login

Because of this my directives do not work. They are set up like this:

        '/Login':
            {
                templateUrl: '/Account/Login',
                controller: 'AccountController'
            },

On the IIS development server this directive calls the route of the Web application:

 http://ipaddress/Account/Login

which should be

http://ipaddress/MyApp/Account/Login

Is there a way to change the directives to work in both cases?

I have tried to play with the "/" character in front of the templateUrl, but it does not seem to work (it gets localhost/Home/Account/Login instead of localhost/Account/Login)

like image 683
dare2k Avatar asked Nov 27 '25 06:11

dare2k


1 Answers

Just ran across this looking for an answer to a similar problem related to hosting an Angular app in an IIS application below a site. I was able to fix the TemplateUrl problem by just adding a . before the /

   '/Login':
        {
            templateUrl: './Account/Login',
            controller: 'AccountController'
        },
like image 146
Jeremy Hutchinson Avatar answered Nov 29 '25 20:11

Jeremy Hutchinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!