Tamseyc
Tamseyc

Reputation: 445

comparing the current url with predetermined url path

How can I check if the the current path is one of the following

http://sitename/dirname3/file1.aspx
http://sitename/dirname3/myfile.aspx

...

using regex.

I know how to get the current path, ie

string currentUrl = HttpContext.Current.Request.Url.AbsoluteUri;

Upvotes: 0

Views: 311

Answers (1)

Rawling
Rawling

Reputation: 50114

Why use a regular expression, rather than just e.g.

HttpContext.Current.Request.Url.AbsoluteUri.StartsWith(pathToCheck);

?

Upvotes: 3

Related Questions