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

  • Home
  • SEARCH
  • 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 148541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:58:38+00:00 2026-05-11T08:58:38+00:00

Branching off from this link it seems that Request.ServerVariables(SCRIPT_NAME) doesn’t return anything. I’ve just

  • 0

Branching off from this link it seems that Request.ServerVariables('SCRIPT_NAME') doesn’t return anything. I’ve just set up a simple loop to see if anything comes out at all but with no luck. Any ideas?

For Each s As String In Request.ServerVariables    Label1.Text += s Next 

ServerVariables brings back a list of Strings in key->value form as defined in System.Collections.Specialized.NameValueCollection

EDIT: It seems to be a problem with getting the ServerVariables from a page using master pages. In my code behind model I’m defining the following:

Public Partial Class Test     Inherits System.Web.UI.Page    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load     Response.Write(Context.Request.ServerVariables('SCRIPT_NAME'))   End Sub End Class 

This doesn’t work, quite simply. If I enter the code within the Page_Load event within the .aspx page, however, by doing the following:

<% Response.Write(Context.Request.ServerVariables('SCRIPT_NAME')) %> 

Then it works fine. Any ideas as to why that’s happening?

  • 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. 2026-05-11T08:58:38+00:00Added an answer on May 11, 2026 at 8:58 am

    Are you sure you’re not getting this back?

    Using Response.Write from the code behind (either in the page or the master page) will output the string at the top of the page (usually), before the rest of the HTML, etc, which is probably not where you’re expecting to see it.

    I put a literal control on a master page, before the content placeholder:

    On Master: <asp:Literal id='LiteralMaster' runat='server'></asp:Literal> 

    And then setting it’s Text property in the master page’s Page_Load event to:

    LiteralMaster.Text = Context.Request.ServerVariables('SCRIPT_NAME') 

    I also added a literal control in the content placeholder on a page that used this master page:

    On page: <asp:Literal id='LiteralPage' runat='server'></asp:Literal> 

    And in the page’s Page_Load event I had the following:

    LiteralPage.Text = Context.Request.ServerVariables('SCRIPT_NAME') 

    Which resulted in:

    On Master: /LittleTest/UsingMaster.aspx
    On page: /LittleTest/UsingMaster.aspx

    Modifying my page’s Page_Load event to become:

    LiteralPage.Text = Context.Request.ServerVariables('SCRIPT_NAME') Response.Write('From response.write: ' &   Context.Request.ServerVariables('Script_Name')) 

    Resulted in the following display in my browser:

    From response.write: /LittleTest/UsingMaster.aspx
    On Master: /LittleTest/UsingMaster.aspx
    On page: /LittleTest/UsingMaster.aspx

    However, the html looked more like:

    From response.write:/LittleTest/UsingMaster.aspx  <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'          'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>  <html xmlns='http://www.w3.org/1999/xhtml'>   <head>     <title></title>   </head>   <body>     <form name='aspnetForm'        method='post' action='UsingMaster.aspx' id='aspnetForm'>       <div>         On Master: /LittleTest/UsingMaster.aspx         <br />         On page: /LittleTest/UsingMaster.aspx       </div>     </form>   </body> </html> 

    Edit to respond to comment

    You are assigning the string representation of a NameValueCollection element to the contents of your label, this is just the NAME, not the combination of the NAME and the VALUE

    Try the following:

    For Each s As String In Request.ServerVariables   Label1.Text += s & ': ' & Request.ServerVariables(s) Next 

    For more info, take a look at the MSDN docs:

    HttpRequest.ServerVariables

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 117k
  • Answers 117k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Retrieving an element by index is an O(n) operation for… May 11, 2026 at 10:49 pm
  • Editorial Team
    Editorial Team added an answer It suppresses any errors that might happen inside the function.… May 11, 2026 at 10:49 pm
  • Editorial Team
    Editorial Team added an answer It looks like you're not using the click event properly.… May 11, 2026 at 10:49 pm

Related Questions

Branching off from this link it seems that Request.ServerVariables(SCRIPT_NAME) doesn't return anything. I've just
Without access to git and git-submodule, I need to incorporate a shared-ip repository into
How do you update this? I've never seen any current team that actually checks
I have a somewhat complicated branching structure at work (at least for me). It
I have a SVN Repository at my main PC, to which only I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.