Problem with empty page

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

asp.net 3.5

I have a webpage which if it has a querystring attached it'll display some
usefull information. But if no querystring is attached it displays this
content:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252"
http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>

I've tryed to put some logic into the page so when no querystring is used it
should give some values to a Literal control on the page. That code executes
but new value of the Literal isn't visible on the page. In addition this
page also have a masterpage, the html of the masterpage is not sent to the
browser if page have no querystring.

I was hoping to be able to add a noindex tag to the header if the page has
no querystring, so far no luck. Code is executed but the tag never appear in
the head section

HtmlHead header = this.Page.Header;
HtmlMeta keyword = new HtmlMeta();
keyword.Name = "robots";
keyword.Content = "noindex, nofollow";
header.Controls.Add(keyword);

Think this is bad for google ranking, googlebot tryes to index the page (it
crawl the page without using querystring) and find nothing, wants to improve
this

any suggestions?
 
hi

asp.net 3.5

I have a webpage which if it has a querystring attached it'll display some
usefull information. But if no querystring is attached it displays this
content:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252"
http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>

I've tryed to put some logic into the page so when no querystring is usedit
should give some values to a Literal control on the page. That code executes
but new value of the Literal isn't visible on the page. In addition this
page also have a masterpage, the html of the masterpage is not sent to the
browser if page have no querystring.

I was hoping to be able to add a noindex tag to the header if the page has
no querystring, so far no luck. Code is executed but the tag never appearin
the head section

HtmlHead header = this.Page.Header;
HtmlMeta keyword = new HtmlMeta();
keyword.Name = "robots";
keyword.Content = "noindex, nofollow";
header.Controls.Add(keyword);

Think this is bad for google ranking, googlebot tryes to index the page (it
crawl the page without using querystring) and find nothing, wants to improve
this

any suggestions?

Where do you execute it, in the master? Are you sure that it is
executed? Check the code where you check if no querystring is
specified, maybe it never happens...
 
hi

asp.net 3.5

I have a webpage which if it has a querystring attached it'll display some
usefull information. But if no querystring is attached it displays this
content:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=windows-1252"
http-equiv=Content-Type></HEAD>
<BODY></BODY></HTML>

I've tryed to put some logic into the page so when no querystring is used
it
should give some values to a Literal control on the page. That code
executes
but new value of the Literal isn't visible on the page. In addition this
page also have a masterpage, the html of the masterpage is not sent to the
browser if page have no querystring.

I was hoping to be able to add a noindex tag to the header if the page has
no querystring, so far no luck. Code is executed but the tag never appear
in
the head section

HtmlHead header = this.Page.Header;
HtmlMeta keyword = new HtmlMeta();
keyword.Name = "robots";
keyword.Content = "noindex, nofollow";
header.Controls.Add(keyword);

Think this is bad for google ranking, googlebot tryes to index the page
(it
crawl the page without using querystring) and find nothing, wants to
improve
this

any suggestions?

Where do you execute it, in the master? Are you sure that it is
executed? Check the code where you check if no querystring is
specified, maybe it never happens...


I execute it in the page (not master), and I know the code is executed
because I have a breakpoint there which is triggered
 
Where do you execute it, in the master? Are you sure that it is
executed? Check the code where you check if no querystring is
specified, maybe it never happens...

I execute it in the page (not master), and I know the code is executed
because I have a breakpoint there which is triggered

Jeff,

I've tested what you said and I get "noindex, nofollow" as expected

Here's what I have

ContentPage:
-----------------------------

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WCM.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
</asp:Content>

Codebehind

public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HtmlHead header = this.Page.Header;
HtmlMeta keyword = new HtmlMeta();
keyword.Name = "robots";
keyword.Content = "noindex, nofollow";
header.Controls.Add(keyword);
}
}


Master:
-------------------------
<%@ Master Language="C#" AutoEventWireup="true"
CodeBehind="Site1.master.cs" Inherits="WCM.Site1" %>

<!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></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1"
runat="server">

</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

The result page has

<meta name="robots" content="noindex, nofollow" />

Hope this helps
 
Back
Top