Skip to content

Commit

Permalink
feat(templates):fix http response handling related issues #6066 (#6067)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi authored Nov 16, 2023
1 parent 2649201 commit d019505
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
<Watch Remove="*.scss" />
</ItemGroup>

<!--/+:msbuild-conditional:noEmit -->
<ItemGroup Condition=" '$(sample)' == 'AdminPanel' or '$(sample)' == ''">
<BlazorWebAssemblyLazyLoad Include="Newtonsoft.Json.wasm" />
<BlazorWebAssemblyLazyLoad Include="System.Private.Xml.wasm" />
<BlazorWebAssemblyLazyLoad Include="System.Data.Common.wasm" />
</ItemGroup>
<!--/-:msbuild-conditional:noEmit -->
<ItemGroup>
<ProjectReference Include="..\BlazorWeb.Shared\BlazorWeb.Shared.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ private void PrepareGridDataProvider()

return BitDataGridItemsProviderResult.From(data.Items!, (int)data.TotalCount);
}
catch
catch (Exception exp)
{
ExceptionHandler.Handle(exp);
return BitDataGridItemsProviderResult.From(new List<CategoryDto> { }, 0);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void PrepareGridDataProvider()

return BitDataGridItemsProviderResult.From(data!.Items!, (int)data!.TotalCount);
}
catch
catch (Exception exp)
{
return BitDataGridItemsProviderResult.From(new List<ProductDto> { }, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
@if (HttpContext.Request.IsCrawlerClient() is false)
{
<script src="_framework/blazor.web.js"></script>
<script src="scripts/app.js"></script>
<script src="_content/Bit.BlazorUI/scripts/bit.blazorui.js"></script>
<script src="scripts/app.js"></script>
@*#if (sample == "AdminPanel")*@
<script src="_content/Bit.BlazorUI.Extras/scripts/bit.blazorui.extras.js"></script>
@*#endif*@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

if (httpContext.Response.StatusCode is 404)
{
httpContext.Response.Redirect($"not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
}
else if (httpContext.Response.StatusCode is 401)
{
httpContext.Response.Redirect($"not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<MtouchEnableSGenConc>true</MtouchEnableSGenConc>
<EnableSGenConc>True</EnableSGenConc>
<!--/+:msbuild-conditional:noEmit -->
<MtouchInterpreter Condition=" '$(sample)' == 'AdminPanel'">all</MtouchInterpreter>
<MtouchInterpreter Condition=" '$(sample)' == 'AdminPanel' or '$(sample)' == ''">all</MtouchInterpreter>
<!--/-:msbuild-conditional:noEmit -->
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ private void PrepareGridDataProvider()

return BitDataGridItemsProviderResult.From(data.Items!, (int)data.TotalCount);
}
catch
catch (Exception exp)
{
ExceptionHandler.Handle(exp);
return BitDataGridItemsProviderResult.From(new List<CategoryDto> { }, 0);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ private void PrepareGridDataProvider()

return BitDataGridItemsProviderResult.From(data!.Items!, (int)data!.TotalCount);
}
catch
catch (Exception exp)
{
ExceptionHandler.Handle(exp);
return BitDataGridItemsProviderResult.From(new List<ProductDto> { }, 0);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</ItemGroup>

<!--/+:msbuild-conditional:noEmit -->
<ItemGroup Condition=" '$(sample)' == 'AdminPanel'">
<ItemGroup Condition=" '$(sample)' == 'AdminPanel' or '$(sample)' == ''">
<BlazorWebAssemblyLazyLoad Include="Newtonsoft.Json.wasm" />
<BlazorWebAssemblyLazyLoad Include="System.Private.Xml.wasm" />
<BlazorWebAssemblyLazyLoad Include="System.Data.Common.wasm" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected override void OnInitialized()
{
HttpContext.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(7),
MaxAge = TimeSpan.FromDays(1),
Public = true
};
}, null!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

if (httpContext.Response.StatusCode is 404)
{
httpContext.Response.Redirect($"not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
}
else if (httpContext.Response.StatusCode is 401)
{
httpContext.Response.Redirect($"not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected override void OnInitialized()
{
HttpContext.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(7),
MaxAge = TimeSpan.FromDays(1),
Public = true
};
}, null!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

if (httpContext.Response.StatusCode is 404)
{
httpContext.Response.Redirect($"not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
}
else if (httpContext.Response.StatusCode is 401)
{
httpContext.Response.Redirect($"not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected override void OnInitialized()
{
HttpContext.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(7),
MaxAge = TimeSpan.FromDays(1),
Public = true
};
}, null!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

if (httpContext.Response.StatusCode is 404)
{
httpContext.Response.Redirect($"not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-found?url={httpContext.Request.GetEncodedPathAndQuery()}");
}
else if (httpContext.Response.StatusCode is 401)
{
httpContext.Response.Redirect($"not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
httpContext.Response.Redirect($"/not-authorized?redirectUrl={httpContext.Request.GetEncodedPathAndQuery()}");
}
}
});
Expand Down

0 comments on commit d019505

Please sign in to comment.