1

I am creating an ASP.NET 5 Blazor Server application with MudBlazor.

I have a URL https://localhost:44324/OperationsAll?Proj_ID=23407&Tail_Nr=TG6R&Location=N. The query string is used to initialize the data on the OperationsAll page.

It works great in the prerender stage of the lifecyle, retrieving the query string and initializing the page with the correct data in the Oninitialized() method.

In the render stage of the lifecycle when Oninitialized() is run again, the query string has changed to 'https://localhost:44324/OperationsAll?id=1234ASSAf31', with the id always being something different. This, of course, then causes the page to not have the required data for the final render of the page.

An interesting bit of information is that the query string is not being replaced in the web browser address bar, that still remains as https://localhost:44324/OperationsAll?Proj_ID=23407&Tail_Nr=TG6R&Location=N. The query string is being replaced with the random ?id=ASDF!1234 within the HttpContext.

Why is the query string being replaced?

How do I keep the query string from changing during the page lifecycle?

5
  • Do you mean that when Oninitialized() is called for the second time, does your retrieval string change automatically? I don't have your situation, can you provide some code to reproduce the problem? Commented Jan 12, 2023 at 6:10
  • 1
    Here are the links that might help you: ASP.NET Core Razor component lifecycle, Working with Query Strings in Blazor. Commented Jan 12, 2023 at 6:12
  • Yes, the query string is automatically changed within the HttpContext. The web browser address bar is unchanged. I have updated my question with this information. I have previously found and read the links you provided, and they do not provide a solution. Commented Jan 12, 2023 at 16:53
  • Did you do anything special to it? Is it possible to monitor HttpContext? Commented Jan 13, 2023 at 9:39
  • @chen I appreciate your help; I do not know the answers to these questions. From what I have been able to find so far, this might have to do with the way ASP.NET core manages an anonymous user session. I have created a work-around by using a cookie where I store and retrieve the needed query string values. The cookie lives only long enough for the page to complete rendering. Commented Jan 13, 2023 at 16:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.