1+ using CodeBehind . HtmlData ;
2+ using Microsoft . AspNetCore . Http ;
3+
4+ namespace CodeBehind
5+ {
6+ internal class RequestQuery
7+ {
8+ public void AddQueryString ( HttpContext context , string QueryString )
9+ {
10+ if ( string . IsNullOrEmpty ( QueryString ) )
11+ return ;
12+
13+ NameCollection QueryValues = new NameCollection ( ) ;
14+ QueryString TmpQueryString = new QueryString ( ) ;
15+ string [ ] QueryElements = QueryString . Split ( '&' ) ;
16+ foreach ( string element in QueryElements )
17+ {
18+ string [ ] NameValue = element . Split ( '=' ) ;
19+
20+ if ( NameValue . Length > 1 )
21+ TmpQueryString = TmpQueryString . Add ( NameValue [ 0 ] , NameValue [ 1 ] ) ;
22+ else
23+ TmpQueryString = TmpQueryString . Add ( NameValue [ 0 ] , "" ) ;
24+
25+ QueryValues . Add ( NameValue [ 0 ] ) ;
26+ }
27+
28+ string RequestQueryString = context . Request . QueryString . Value ;
29+
30+ if ( ! string . IsNullOrEmpty ( RequestQueryString ) )
31+ {
32+ RequestQueryString = RequestQueryString . GetTextAfterValue ( "?" ) ;
33+ string [ ] TmpQueryElements = RequestQueryString . Split ( '&' ) ;
34+ foreach ( string element in TmpQueryElements )
35+ {
36+ string [ ] NameValue = element . Split ( '=' ) ;
37+
38+ if ( ! QueryValues . Exist ( NameValue [ 0 ] ) )
39+ if ( NameValue . Length > 1 )
40+ TmpQueryString = TmpQueryString . Add ( NameValue [ 0 ] , NameValue [ 1 ] ) ;
41+ else
42+ TmpQueryString = TmpQueryString . Add ( NameValue [ 0 ] , "" ) ;
43+ }
44+ }
45+
46+ context . Request . QueryString = TmpQueryString ;
47+ }
48+ }
49+ }
0 commit comments