question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using PageLoader for multiple endpoints can cause the loss of endpoint metadata

See original GitHub issue

Describe the bug

I’m using PageLoader per @davidfowl’s recommendation to get the full metadata for multiple endpoints on a single razor page. I’ve noticed that after I’ve loaded an endpoint via PageLoader that hasn’t been visited via an HTTP request, then there is metadata missing that would normally be there without using PageLoader.

For example, if I call endpoints.MapRazorPages().WithMetadata("Some Metadata") and then inspect the endpoint in middleware during a normal request the custom metadata exists on the endpoint. But if I load the endpoint with PageLoader first before doing an actual HTTP request then the custom data does not exist on the endpoint.

During a normal request PageLoaderMatcherPolicy specifically calls DefaultPageLoader.LoadAsync() with the original endpoint metadata and then enriches it with the compiled metadata and then caches the value. Unfortunately, the PageLoader.LoadAsync(PageActionDescriptor actionDescriptor, EndpointMetadataCollection endpointMetadata) method is marked internal so I can’t pass along the original endpoint metadata so the endpoint is cached with missing metadata. See my linked GitHub repo below for an example of this.

Is there a better way for me to get all the endpoints in my app with their full metadata other than calling PageLoader? Or should I be calling PageLoader differently?

To Reproduce

See an example at https://github.com/jeffpapp/PageLoaderSample/tree/main/PageLoaderSample

If you run the sample project and follow the Go to Next Page links you will see that the third page is missing the custom metadata on it’s endpoint because the second page called PageLoader which overrode the default behavior of PageLoaderMatcherPolicy and cached an endpoint without all the metadata you’d expect.

Further technical details

  • ASP.NET Core version: 5.0.6
  • Include the output of dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19041
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100\

Host (useful for support):
  Version: 5.0.6
  Commit:  478b2f8c0e

.NET SDKs installed:
  3.1.402 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]
  5.0.203 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version: VS 2019 16.9.6

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
davidfowlcommented, Oct 22, 2021

Can we look at this for .NET 7? It seems like here’s an easy fix here.

0reactions
msftbot[bot]commented, Nov 11, 2021

We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get WCF metadata through endpoint address
I have a wcf service exposing multiple endpoints including a mex endpoint. I have enabled getting the metadata over http and https. My...
Read more >
Bypass Metadata Endpoint Checks | University IT
When SPs are used to protect sites with multiple virtual hosts, each virtual host must use its own domain name in its handler...
Read more >
RHSA-2020:5633 - Security Advisory
Space precludes documenting all of the container images in this advisory. ... loop in encoding/unicode could lead to crash (CVE-2020-14040) ...
Read more >
Change log for 4.7.43 - OpenShift Mirror
Exists() to find a host in the unmanaged state #130 · Bug 1868104: Make use of errors and Failed ... inspect: add example...
Read more >
npmsearchfullcat_npm143.txt - GitHub
=jtblin 2014-02-24 0.0.6 model inherit extend augment object validation active active-sender A node.js library for sending e-mail through multiple…
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found