Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 954913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:17:37+00:00 2026-05-16T00:17:37+00:00

I am trying to make 2 variables available throughout my site. I am parsing

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:17:38+00:00Added an answer on May 16, 2026 at 12:17 am

    You can use System.Web.HttpContext.Current.Request to get the request object for the current thread.

    A better way to get your country and language folders is to use Request.Url.Segments.

    Public Class url_parser
        Public Shared Function urlLanguage() As String
            Dim Request = Web.HttpContext.Current.Request
            Return Request.Url.Segments(1).TrimEnd("/"c)
        End Function
    
        Public Shared Function urlCountry() As String
            Dim Request = Web.HttpContext.Current.Request
            Return Request.Url.Segments(2).TrimEnd("/"c)
        End Function
    End Class
    

    Access these static function this way.

    Dim MyLanguage = url_parser.urlLanguage
    Dim MyCountry = url_parser.urlCountry
    

    In this example, if the Url is “/en/us/” then…

    • Segment(0) is “/”
    • Segment(1) is “en/”
    • Segment(2) is “us/”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a simple in in-page popup called like this: var test
I trying to make automatic variables available to Excel VBA (like ActiveSheet or ActiveCell)
I am trying to make a JTable that has column spans available. Specifically, I
Is the proper way to make a few variables available to all my controllers
I am trying to make a Date() class, however I think my variables may
I'm trying to make a login and logout script for a page but for
I'm trying to concatenate a url together in xsl. Basically, I'm taking two variables
I'm trying to make a web page with a fixed header and a scrollable
Trying to make a make generic select control that I can dynamically add elements
Trying to make a MySQL-based application support MS SQL, I ran into the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.