1
我正在使用ng-viewport在index.html中显示我的页面,在HTML 5模式下,当我们打开基础URL(例如http://localhost:86)时,一切正常工作,并转到(http://localhost:86/app/dashboard)这是我的家或着陆页,并且所有其他重新方向正常工作。HTML 5模式深层链接和刷新不工作AngularJS
问题出现在我们直接尝试打开完整的URL(例如http://localhost:86/app/dashboard)时,它正在加载我的index.html页面,但只显示静态内容(如徽标和图像),并且未显示我的动态网页在ng-viewport部分中显示。在重新加载任何页面时都有相同的行为。
以下是我写的代码。
JS代码。
$locationProvider.html5Mode({ enabled: true });
HTML代码
<head>
<base href="/"/>
</head>
<body>
<div>
<img class="rotate" src="../assets/img/logo_img.png" />
</div>
<div style="height: 100%" ng-viewport autoscroll>
</div>
</body>
的Web.Config
<?xml version="1.0" encoding="UTF-8"?>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="iisstart.htm" />
<add value="default.aspx" />
</files>
</defaultDocument>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="App_Data" />
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<rule name="AngularJS" enabled="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(Api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
路由配置代码
static $routeConfig = [{
path: '/dashboard/:type',
component: 'dashboard'
}, {
path: '/dashboard',
component: 'dashboard'
}, {
path: '/mail',
component: 'mail'
}, {
path: '/solution/:id',
component: 'solutionDetails'
}]