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

The Archive Base Latest Questions

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

I am trying to redirect a page reading the url from the config file.

  • 0

I am trying to redirect a page reading the url from the config file.

However, when I try this:

   <script type="text/javascript">
<%string redirectUrl = System.Web.Configuration.WebConfigurationManager.AppSettings["RedirectURL"];%>
    window.parent.location.replace("<%=redirectUrl%>");
</script>

the alligator tags <% %> are Not being highlighted, and when I run I get the following error in the yellow screen:

the controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

What am I doing wrong??

Thanks!

Edit:

It does work if I just put the url straight into the code, as in

window.parent.location.replace("http://theurl.com");

but I need to change this depending on other things, so I need it to be in the config :S

  • 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-14T05:34:20+00:00Added an answer on May 14, 2026 at 5:34 am

    You’re probably including the block inside a

    <head runat="server"> ... </head> 
    

    block. If you want to use <% %> blocks you need to remove the runat=”server” from the head tag but then you’ll lose the Page.Title and some other features.

    In your particular case, doing

    window.parent.location.replace("<%= System.Web.Configuration.WebConfigurationManager.AppSettings["RedirectURL"] %>");
    

    should fix the problem, i.e. get rid of the <% %> tags.

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

Sidebar

Related Questions

I'm trying to redirect from child page to parent page with this javascript: ScriptManager.RegisterClientScriptBlock(this,
I'm trying to redirect after page + images load: function redirect_on_load(){ //called from script
I'm trying a redirect on a page that goes like this: original URL: http://www.foo.com/products/
I'm trying to redirect this page Page to a Jquery mobile website that I'm
I am trying to redirect everything to a single page from my /website/folder/ directory.
I am trying to using Nginx to redirect from /t/latest/2 to /topics/latest/page/2 rewrite ^/t/latest$
I'm trying to redirect a page via JavaScript: window.location('http://www.google.com'); but in firefox, I'm getting
I'm trying to redirect from one page to another while retaining the parameters. e.g.
I'm trying to redirect a page using javascript output using php. The problem I'm
I am trying to redirect a login page to an external security service. This

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.