app-routing.module.ts:
const routes: Routes = [
{ path: "", component: MapComponent },
{ path: "map/:lookupValues", component: MapComponent },
]
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
export class AppRoutingModule { }
在map.component.ts中,我正在阅读以下参数:
this.snapshotParam = this.route.snapshot.paramMap.get("collaterals");
var inputData = this.snapshotParam.split('_');
URL如下所示:
http://localhost:4203/map/val1_val2_val3... [length < 1000 bytes ]
大约300个字符的长度后,出现以下错误:
此有角应用程序托管在IIS上(我检查了默认的“请求过滤”是否具有最大URL长度为4096字节,而我的请求是<1000字节(当然,假设1个字符= 1字节)
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime maxUrlLength="4096" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<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>
</system.webServer>
</configuration>
使用?lookupValue=val1_val2_val3...
并没有出现此错误,但是我正在使用ActivatedRouter
模块来解析参数。我在这里想念什么吗?还是有一种方法可以使用ActivatedRouter以查询字符串格式(即?lookupValue=val1_val2_val3...
)读取参数?