There are two URLs I have:
http://localhost:65043/home/create/
http://localhost:65043/home/create/2
I want to check that the ID exists in the URL or not. If yes, then I need to parse them, otherwise I got 0.
How I can get the ID from the URL and if they not, have that get 0 from that and return a thing that shows that “It is new. No ID exists with URL”
How I can do this?
If you want to do it all at once in a silly way, you can reverse the URL and put it into a parseInt. Then test if it is a number. So you don’t need to know where the URL is running, only to check if the last part of the path is an ID.
But as you can see, that gets quite unreadable. (And is about four times slower.)
It basically: