URL参数大于使用ActivatedRoute的特定长度,导致IIS中出现400错误

时间:2019-03-18 18:29:33

标签: angular iis angular-router

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个字符的长度后,出现以下错误:

Response

此有角应用程序托管在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...)读取参数?

0 个答案:

没有答案