0

I have this rule in my web.config that looks like this:

<rule name="netball.html" stopProcessing="true">
  <match url="netball.html" />
  <action type="Redirect" url="/netball" redirectType="Permanent" />
</rule>

but I have a route in angular setup like this:

.state('netball', {
    url: '/netball',
    templateUrl: '/assets/tpl/sports/netball.html',
    controller: 'SportsController',
    controllerAs: 'controller',
    data: {
        pageTitle: 'Netball'
    }
})

For some reason the redirect rule is messing with my route. If I remove that rule, the netball view works fine. If I add it in, doesn't work at all (shows the index page, but the ui-view is empty like it can't find the template.

Because of this, I decided to change the templateUrl to

templateUrl: '/assets/tpl/sports/test.html',

and that works. So, there is something going on with angularJS and how it displays the view. Is there anything I can do (apart from renaming all my views to something that won't get matched by a redirect rule) to stop this happening?

1 Answer 1

1

It makes sense if you think about it. Your angular app is making a HTTP GET request for /assets/tpl/sports/netball.html when it tries to load the template for the route. BUT IIS is saying "when a request with "netball.html" comes in, redirect it to "/netball".

I would suggest that you adopt a naming convention for templates, e.g. "netballTemplate.html", that way you won't get any clashes.

Sign up to request clarification or add additional context in comments.

2 Comments

Don't forget to upvote, if you like the answer. I need the reputation points! Thanks!
Done, it wouldn't let me before :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.