Asp.NET/VB.NET: Getting path from URL / URI?
Let's say I have a project that I am deploying to
www.foo.com/path1/default.aspx
and
www.foo.com/path2/default.aspx
What would be the most reliable way to know if I was in the "path1" or "path2" folder? Can I get this directly or do I need to split () somehow into Request.Url.AbsolutePath or ...?
I just want to change colors etc. based on the folder the user is in.
Thanks for any help!
If you want to code this logic directly in the page, then yes, I would go with split () to Request.Url.AbsolutePath.
However, I would consider storing this type in the AppSettings section of the web.config file. Thus, if you decide to change the color in path2, you just need to edit the web.config file for path2. If you need to add a new path, just expand it and edit the web.config file accordingly.
a source to share