I am trying to make 2 variables available throughout my site. I am parsing the URL in order to retreive both of them.
This code on the page itself works fine.
Dim countryLanguage As String
countryLanguage = (Request.ServerVariables("URL"))
Dim langVar = (Mid(countryLanguage, 2, 2))
Dim countryVar = (Mid(countryLanguage, 5, 2))
I have created a class file the code for which is below. With this I get a complilation error (BC30451: Name ‘Request’ is not declared.).
Public Class url_parser
Public Shared Function urlVars(ByVal langVar, ByVal countryVar) As String
Dim countryLanguage As String
countryLanguage = (Request.ServerVariables("URL"))
Dim langVar = (Mid(countryLanguage, 2, 2))
Dim countryVar = (Mid(countryLanguage, 5, 2))
End Function
End Class
Thanks
You can use
System.Web.HttpContext.Current.Requestto get the request object for the current thread.A better way to get your country and language folders is to use
Request.Url.Segments.Access these static function this way.
In this example, if the Url is “/en/us/” then…