Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the last part of URL
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Titre:
Getting the last part of URL
Versions des environnements
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01659359
Message ID:
01659359
Vues:
41
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform