I can use this <%= Request.ServerVariables["SERVER_NAME"] %> to get the server name of the current page. How do I get just the last three characters? All I want is the dev or stg or org part.

Recommended Answers

If you are using Linq; ...

string strExtension = Request.ServerVariables["SERVER_NAME"].Split('.').Last();
Jump to Post

All 2 Replies

If you are using Linq; ...

string strExtension = Request.ServerVariables["SERVER_NAME"].Split('.').Last();

?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.