How to change angularJS directive for IIS default website

I am building a web application with ASP.NET MVC and AngularJS. When I debug a web application, the url looks like this:

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

When I publish it on the IIS development server, I use then I use the default website, so the URL will be like this:

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

Because of this, my directives do not work. They are configured as follows:

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

On the IIS development server, this directive calls the web application route:

 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 tried playing with the "/" character before the Url pattern, but it does not work (it gets localhost / Home / Account / Login instead of localhost / Account / Login)

+3
source share
3

, , Angular IIS . TemplateUrl, . /

   '/Login':
        {
            templateUrl: './Account/Login',
            controller: 'AccountController'
        },
+3

, :

0

url ,

<base href="/MyApp">

For the differential between dev and release, conditional compilation is used. See Here C # and ASP.NET MVC: Using the #if Directive in a View

0
source

All Articles