-
Aug 17th, 2023, 10:09 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Having problems with navigationManager and a null parameter
I have a page SystemDataDetails from which I want to navigate to CircuitDetails. Circuits are represented in a grid on SystemDataDetails and you click a row and open the circuit page. I realized I have half the data already in the row that I want to display on the next page so instead of making the next page call the database to get the remaining data, I decided to put all the data in the row (some of it in columns that aren't visible) and I can just pass a boatload of parameters. I didn't know if that was a bad design decision or not - saving a database call vs passing a lot of parameters.
The problem I'm having is one of the parameters is null. I kept getting "there is nothing at this address" and found it's because providerName is null.
Here is the call and the page:
Code:
navigationManager.NavigateTo($"circuitdetail/{item.CircuitID}/{item.SiteA}/{item.SiteB}/{item.CircuitType}/{item.CircuitUse}/{customerSystem.OwnerID}/{customerSystem.customer_name}/{item.ProviderName}/{item.CircuitBW}/{item.CircuitNotes}");
@page "/circuitdetail/{circuitID}/{siteA}/{siteB}/{type}/{use}/{custno}/{custname}/{provider}/{bandwidth}/{notes}"
I tried testing for item.ProviderName being null and passing an empty string but it wasn't happy with that either.
I'm sure with this one particular test case I am just getting lucky that only one of the parameters is null and it will happen with other circuits that other parameters are null.
So, my ideas to fix is don't pass so many parameters and let CircuitDetails make the call. Or of course understand how to handle null parameter passing. Can you point me in the best direction?
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
-
Aug 17th, 2023, 12:29 PM
#2
Re: Having problems with navigationManager and a null parameter
this is all opinion... but ...
data like that should never be passed around on the URL... at most, you should only be providing just enough details to look up the data. Otherwise your second page becomes dependent on the first ... now when you need to add another piece of data, now you'd have to change two pages... plus now you also need that info in the first just so it can pass it to the second. Yeah, sure it seems simple to just pass it when you've got half the data, but it's a bad idea. You're already going to be making a trip to get the other half of hte data anyways... so just pass over hte minimum needed to get the data no more, no less.
-tg
-
Aug 17th, 2023, 01:10 PM
#3
Thread Starter
PowerPoster
Re: Having problems with navigationManager and a null parameter
@tg - I understand what you're saying, thank you, and all opinions are welcome from those of you way more experienced than I! Let me just repeat the scenario so I know we're clear. One the first page I make a database call to get some data. It seemed more efficient to me, rather than make a second call to get more data on the second page, to just make the one call and get it all. Of course, web may be different than windows in this regard, and I realize it's a lot of parameters to have to deal with.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
-
Aug 17th, 2023, 05:33 PM
#4
Re: Having problems with navigationManager and a null parameter
I didn't say you can't.... I said you shouldn't. I personally wouldn't... there's to much that could go wrong... data that isn't encoded correctly -- this is something we had to deal tih this week when an user tried to enter something with a / in it, and it broke the route it was intended for. There's also only so much you can shove into the URL - there's a length limit. You've also exposed the data raw to the user... what if they then monkey with the data in the url and submit it? I know it seems like it's efficient, but in the end it really isn't. It's also horribly insecure.
-tg
-
Aug 18th, 2023, 10:40 AM
#5
Thread Starter
PowerPoster
Re: Having problems with navigationManager and a null parameter
I am learning. I don't mind deferring to other people's advice. Thank you, changing it now. At the very least, it will solve my null parameter problem.
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|