Let say you have next rewrite rule:
<rule name="Force trailing slash" stopProcessing="true">
<match url="(.*[^/])" />
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}/" appendQueryString="true" redirectType="Permanent" />
</rule>
You have to add conditions to avoid redirection of URL that are paths that should not be redirected (paths to files or specific Sitecore paths):
<rule name="Force trailing slash" stopProcessing="true">
<match url="(.*[^/])" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^.*\.css$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^.*\.aspx$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^.*\.js$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^.*\.ashx$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^sitecore.*\.js$" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}/" appendQueryString="true" redirectType="Permanent" />
</rule>