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 128883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:42:20+00:00 2026-05-11T05:42:20+00:00

Question I’m trying to build a quick and easy ASP.NET page that redirects a

  • 0

Question


I’m trying to build a quick and easy ASP.NET page that redirects a user to a new URL using a meta redirect. Only trouble is that I need to also pass along the GET values of the current request. I’ve found a way to do this programatically in the code behind using the HtmlMeta object. However, I’d like to avoid using the code behind and just put this code directly into the ASPX page.

Here is what I have so far:

<!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 runat='server'>     <title>Untitled Page</title>     <meta http-equiv='refresh' content='10;url=http://contact.test.net/main.aspx?<%=Request.QueryString.ToString()%>' /> </head> </html> 

However, this spits out the following meta tag:

<meta http-equiv='refresh' content='10;url=http://contact.test.net/main.aspx?<%=Request.QueryString.ToString()%>' /> 

So is there any way to escape the attribute so the ASP.NET code actually executes?

Solution 1


For the time being, I have fixed my problem by removing the quotes from the HTML attribute. Thus making the meta tag the following:

  <meta http-equiv='refresh' content=10;url=http://contact.test.net/main.aspx?<%=Request.QueryString.ToString()%> />   

Although this fixes the issue, I’d be curious if anyone knows of a more correct way to do it where I could escape the literal quotes of the HTML attribute.

Solution 2 (Final Chosen Solution)


Per the much appreciated advise of Scott, I decided to go ahead and do this from the code behind. For anyone who is curious how this was implemented:

      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load         Dim nRef As String = Request.QueryString('n')         Dim sRef As String = Request.QueryString('s')          Dim contentAttrBuilder As New StringBuilder('0;http://contact.cableone.net/main.aspx')         contentAttrBuilder.Append('?n=')         contentAttrBuilder.Append(nRef)         contentAttrBuilder.Append('&s=')         contentAttrBuilder.Append(sRef)          Dim metaRedirect As New HtmlMeta()         metaRedirect.HttpEquiv = 'refresh'         metaRedirect.Content = contentAttrBuilder.ToString()          Me.Header.Controls.Add(metaRedirect)      End Sub  

Thanks,
Chris

  • 1 1 Answer
  • 1 View
  • 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-11T05:42:21+00:00Added an answer on May 11, 2026 at 5:42 am

    Maybe this code inside the head tag will be what you need:

    <%= string.Format('<meta http-equiv='refresh' content='10;url=http://contact.test.net/main.aspx?{0}' />', Request.QueryString.ToString()) %> 

    However, I wouldn’t advise you to do it this way. For example, this URL:

    http:/mysite.with.metaredirect?<script>alert('hello!!!')</script> 

    will throw an exception in asp.net if you haven’t disabled its security features, and you never know if someone (or even yourself) will turn those off for some other reason.

    A code-behind massage of the querystring is strongly advised!

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

Sidebar

Related Questions

My question is about memory use and objects in actionscript 2. If I have
I need to solve the following question which i can't get to work by
Every time that I want to do a Layout, I'm getting a black layout
I've found several jQuery syntaxes for nullifying the enter on a form. First one:
After having read Ian Boyd 's constructor series questions ( 1 , 2 ,
I would like to remove/delete a migration file. How would I go about doing

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.