Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check does url containt some word in C#?

Tags:

c#

asp.net

razor

I have an URL that goes something like this http://www.dev.example.com and some URL that is like this http://www.test.example.com.

I dont know where dev and test word would be, maybe on the end maybe, on beggining. What i need to do is to check does url has some word and do something , her is something i need

var test = "test";
if (Request.Url.AbsoluteUri **have** test)
{
   /// Do something
}
like image 922
Schneider Avatar asked Jan 29 '26 06:01

Schneider


1 Answers

You should try this

var test = "test";

 if (Request.Url.AbsoluteUri.Contains(test))
{
   /// Do something
}
like image 112
nsgocev Avatar answered Jan 31 '26 20:01

nsgocev