I’m looking to write some C# that will detect a piece of a URL and change some text based on the URL found on Page Load.
Essentially, I want this to happen:
- URL is detected as ending with “.us || .com” OR “.ca”
- Change the text of an
<h1>to say “United States” or “Canada” based on the URL found.
My C# experience with this sort of code is almost 0, so I don’t have any code to show, because I don’t know where to start. Can anyone help me get in the right direction?
You can use the Uri class and view the
Hostproperty to see if it contains.us,.com, or.cawith a simple stringEndsWithoperation.Please keep in mind that when constructing the
Uriclass, you must pass in a valid URI.