PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Asp.net masterpage content rendering above all other content

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Asp.net masterpage content rendering above all other content

    I've followed the instructions here http://www.wrensoft.com/zoom/support/aspdotnet.html for using the cgi method for including the search within an asp.net masterpage.

    I have placed the code inside my contentplaceholder and added the import statements.

    I have also removed everything from the template html except

    Code:
    <h1>Search this site</h1>
    	<p>
    	Enter one or more keywords to search for using the Zoom Search Engine.<br />
    	Note that '*' and '?' wildcards are supported.
    	</p>	
    	<!--ZOOMSEARCH-->
    I have also placed some test text either side of the <% %> tags and that renders in the correct place, but the zoom output renders at the very top of the html, above the masterpage content, which causes the page to render almost blank.
    I.e. I see this at the top of View Source, with the rest of the page below it:
    Code:
    <h1>Search this site</h1> 
    	<p> 
    	Enter one or more keywords to search for using the Zoom Search Engine.<br /> 
    	Note that '*' and '?' wildcards are supported.
    	</p>	
    	<!--Zoom Search Engine Version 6.0 (1020) PRO-->
    Any idea what I've missed?
    ASP.NET 3.5, C#.

  • #2
    If you are using the ASP.NET wrapper code to display the CGI results, they should output where you have the line:
    Code:
    Response.Write(zoom_results);
    ..as part of the wrapper code.
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment


    • #3
      Yes it should, but it doesn't.

      Full code:

      Code:
      <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Search.master.cs" Inherits="XXX.MasterPages.Search" MasterPageFile="/masterpages/Master.master" %>
      <%@ Import Namespace="System.IO" %>
      <%@ Import Namespace="System.Diagnostics" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="MasterContentPlaceHolder1" runat="server">
      	Test
          <%
              string paramStr = "";
              int parampos = Request.RawUrl.IndexOf("?");
              if (parampos >= 0)
                  paramStr = Request.RawUrl.Substring(parampos + 1);
      
              ProcessStartInfo psi = new ProcessStartInfo();
              psi.FileName = Server.MapPath("search.cgi");
              psi.EnvironmentVariables["REQUEST_METHOD"] = "GET";
              psi.EnvironmentVariables["QUERY_STRING"] = paramStr;
              psi.EnvironmentVariables["REMOTE_ADDR"] = Request.ServerVariables["REMOTE_ADDR"];
              psi.RedirectStandardInput = false;
              psi.RedirectStandardOutput = true;
              psi.UseShellExecute = false;
              Process proc = Process.Start(psi);
              proc.StandardOutput.ReadLine(); // skip the HTTP header line
              string zoom_results = proc.StandardOutput.ReadToEnd(); // read from stdout 
              proc.WaitForExit();
              // Print the output
              Response.Write(zoom_results);
          %>
          Test
      </asp:Content>

      Comment


      • #4
        OK. Within a Content Place Holder, things are quite different. You'll need to assign the zoom_results string to a placeholder literal tag instead of writing it out in real-time.

        See this forum thread for an example:
        http://forums.asp.net/t/946955.aspx

        The difficult thing with answering ASP.NET questions (and finding ASP.NET answers online) is that there are so many different ways to do something and there are too many radically different models.
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment

        Working...
        X