@@ -43,6 +43,28 @@ public async Task Invoke(HttpContext context)
4343 }
4444}
4545
46+ public class UseCodeBehindNextNotFoundMiddleware
47+ {
48+ private readonly RequestDelegate _next ;
49+
50+ public UseCodeBehindNextNotFoundMiddleware ( RequestDelegate next )
51+ {
52+ _next = next ;
53+ }
54+
55+ public async Task Invoke ( HttpContext context )
56+ {
57+ CodeBehind . CodeBehindExecute execute = new CodeBehind . CodeBehindExecute ( ) ;
58+
59+ string PageResult = execute . Run ( context ) ;
60+
61+ if ( execute . FoundPage )
62+ await context . Response . WriteAsync ( PageResult ) ;
63+ else
64+ await _next ( context ) ;
65+ }
66+ }
67+
4668public class UseCodeBehindRouteMiddleware
4769{
4870 private readonly RequestDelegate _next ;
@@ -74,17 +96,39 @@ public async Task Invoke(HttpContext context)
7496 {
7597 CodeBehind . CodeBehindExecute execute = new CodeBehind . CodeBehindExecute ( ) ;
7698
77- string PageResult = execute . Run ( context ) ;
99+ string PageResult = execute . RunRoute ( context , 0 ) ;
78100
79- if ( execute . FoundPage )
80- await context . Response . WriteAsync ( execute . RunRoute ( context , 0 ) ) ;
101+ if ( execute . FoundController )
102+ await context . Response . WriteAsync ( PageResult ) ;
81103 else
82104 await context . Response . WriteAsync ( execute . RunErrorPage ( 404 , context ) ) ;
83105
84106 await _next ( context ) ;
85107 }
86108}
87109
110+ public class UseCodeBehindRouteNextNotFoundMiddleware
111+ {
112+ private readonly RequestDelegate _next ;
113+
114+ public UseCodeBehindRouteNextNotFoundMiddleware ( RequestDelegate next )
115+ {
116+ _next = next ;
117+ }
118+
119+ public async Task Invoke ( HttpContext context )
120+ {
121+ CodeBehind . CodeBehindExecute execute = new CodeBehind . CodeBehindExecute ( ) ;
122+
123+ string PageResult = execute . RunRoute ( context , 0 ) ;
124+
125+ if ( execute . FoundController )
126+ await context . Response . WriteAsync ( PageResult ) ;
127+ else
128+ await _next ( context ) ;
129+ }
130+ }
131+
88132public class UseRoleAccessMiddleware
89133{
90134 private readonly RequestDelegate _next ;
@@ -145,6 +189,11 @@ public static IApplicationBuilder UseCodeBehind(this IApplicationBuilder builder
145189 return builder . UseMiddleware < UseCodeBehindMiddleware > ( ) ;
146190 }
147191
192+ public static IApplicationBuilder UseCodeBehindNextNotFound ( this IApplicationBuilder builder )
193+ {
194+ return builder . UseMiddleware < UseCodeBehindNextNotFoundMiddleware > ( ) ;
195+ }
196+
148197 public static IApplicationBuilder UseCodeBehindRoute ( this IApplicationBuilder builder )
149198 {
150199 return builder . UseMiddleware < UseCodeBehindRouteMiddleware > ( ) ;
@@ -158,6 +207,11 @@ public static IApplicationBuilder UseCodeBehindRoute(this IApplicationBuilder bu
158207 return builder . UseMiddleware < UseCodeBehindRouteMiddleware > ( ) ;
159208 }
160209
210+ public static IApplicationBuilder UseCodeBehindRouteNextNotFound ( this IApplicationBuilder builder )
211+ {
212+ return builder . UseMiddleware < UseCodeBehindRouteNextNotFoundMiddleware > ( ) ;
213+ }
214+
161215 /// <summary>
162216 /// Session Must Be Activated
163217 /// </summary>
0 commit comments