Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the last part of URL
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
MVC
Title:
Getting the last part of URL
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01659359
Message ID:
01659359
Views:
42
Hi everybody,

I'm very close (hopefully). I need to compare last portion of URL with my string to avoid re-directing too many times.

So, I have

https://stackoverflow.com/questions/8185313/how-to-obtain-the-current-url
string invalidLicensePath = "importlicenses";

            string currentUrl = Request.Url.Segments[1];
                        
            if (currentUrl.ToLower() != invalidLicensePath)
            {
                //filterContext.Result = new RedirectResult(changePasswordPath);
                filterContext.Result = new RedirectResult(@"~/DataMaintenance/ImportLicenses");
            }
but when I was looking in the debugger it's actually Segments[3] in my case.

How can I modify the code above to get the last portion of my URL?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform