views:

46

answers:

3

When I render a page in ASP.NET, the following happens

</head>
<NOSCRIPT>
<meta http-equiv="REFRESH" content="0;URL=/Default.aspx?id=84&epslanguage=en-GB&jse=0" />
</NOSCRIPT>
<title>Page title goes here.</title>
<body>

My masterpage looks like this:

<title>Page title goes here.</title>
</head>
<body>

So what I'm asking is, where the heck has this refresh meta tag come from, why has it put it between my head tag and body tag, and why has my page title jumped outside of the head?!

When viewing the page's generated source in firebug, it shows the title tag and this new meta tag within the head tag, but viewing the source in any browser, it looks like the above. When using wget to scrape the page, it also comes out incorrectly as displayed above.

Any ideas why browsers may be interpreting this in different ways, and more importantly where this new meta tag has come from?

Thanks! Karl.

Edit:

Hi!

Thanks for your replies guys, very informative!

I've discovered that the problem is this line of code:

Page.Header.Controls.Add(ctrl);

Putting the mysterious meta tag in using this line puts it outside the head tag. When commenting this out, the title tag drops back into the right place, and all is well!

Any further thoughts?

Thanks!

Karl.

A: 

On the matter of why browsers will be interpreting it differently there are two answers. Firstly the firebug output as you say is generated source. That means its gone through a certain amount of processing already and clearly firefox is doing some magic to say "Well, its a meta and a title tag, they should be in the header so I'll put them there."

The other browsers you are comparing their raw source it sounds like which is before the browser has tried to make sense of it. I suspect you'd get the same if you viewed the raw source in firefox (ctrl-u).

I'd have expected all browsers to do much the same thing as you have described firefox as doing but if not then that's not really somethign to be concerned about. When invalid HTML like this is received the browsers have no real rules of what to do. This means that browsers are welcome to do whatever they want from trying to guess what you meant to just ignoring it entirely.

As for what is causing it, the epslanguage query paramter is from episerver - I don't know if that was in the request url or not so it may be that it is just being persisted or it may be episerver trying to redirect to a page with an explicit language instead of just assuming the default. Unfortunately I'm not familiar with episerver so I can't say any more specific to that.

It is of course definitely the case that there is something on your server side that is causing this to happen.

Do you get that for all pages out of interest or just one specific one or just in one specific circumstance?

Chris
Thanks for your replies guys! I've edited my question with a bit more information about what I've found out!
Karl
@Karl: Can you post a little more of your master page? Mainly the bits up from where you started so we have the complete head element visible...
Chris
A: 

Quite often it's a case of an element not being properly closed. Most browsers will try to adjust the markup so that it makes sense, but in most cases the markup will be incorrectly parsed.

You should probably share more of your master page (and the web form using it)!

Ted Nyberg
A: 

Maybe your HEAD-tag doesn't have runat="server"?

Johan Kronberg