Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2007, 08:20 AM
Authorized User
 
Join Date: Feb 2007
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to toddw607 Send a message via Yahoo to toddw607
Default Web.Config problem?

Hi Everyone!
      I have a aspx page that when accessed through the web server it brings up a dropdown box connected to names of three different .aspx pages which are derived from 3 different SQL Server 2000 tables. When bringing up the initial page and when a selection is made from the dropdown box it displays a 404 error.
      I'm sure it is not the code (which I will include at the bottom) because when I bring up the actual .aspx page in visual basic and right click to "View in Browser" the page and the links work fine. Also, when trying to access the links directly (without using the dropdown box) they also come up with a 404 error. I think this probably has to do something with the web.config file but everytime I try to move the file from the parent directory of my folder, the main page does not even come up. I tried to place it within my folder but the same error is displayed. I think I may have to set up a different web.config for each page but I'm not sure how to do this and I also read that I shouldn't have to. Also, all 4 pages are located in the same folder. I think I have covered everything I'm away of but if there is anything else needed to attempt to solve this problem please let me know Thanks!!

  Code for Initial page:
     <%@ Page Language="VB" %>
<script language="VB" runat="server">

    Sub Page_Load(sender As Object, e As EventArgs)
        Dim blnAutoNav As Boolean

        If Not Page.IsPostBack Then
            ' Create a new ListItemCollection
            Dim myLocations As New ListItemCollection()

            ' Add items to the collection
            myLocations.Add(New ListItem("Select a Table to Display", Request.ServerVariables("URL")))
            myLocations.Add(New ListItem("ToddsTable1", "ToddsTable1.aspx"))
            myLocations.Add(New ListItem("CA", "CA.aspx"))
            myLocations.Add(New ListItem("XH", "XH.aspx"))

            ' Databind our DDL to the ListItemCollection we just filled
            ddlLocations.DataSource = myLocations
            ddlLocations.DataTextField = "Text"
            ddlLocations.DataValueField = "Value"
            ddlLocations.DataBind()
        End If

        ' Find out current auto-navigation status and add JS to handle it if needed.
        If Request.QueryString("auto") = "True" Then
            blnAutoNav = True

            ' This adds the javascript to automatically redirect to the selected
            ' location whenever a new item is selected in the dropdownlist.
            ddlLocations.Attributes("onchange") = "javascript:window.location = " _
                 & "document.frmNav.ddlLocations[document.frmNav.ddlLocations.selectedIndex].value;"
        Else
            blnAutoNav = False
        End If


    End Sub

    Sub btnGo_Click(sender As Object, e As EventArgs)
        Response.Redirect(ddlLocations.SelectedItem.Value)
    End Sub

</script>

<html>
<head>
<title>Collection of Tables from SQL Server displayed in ASP.NET</title>
<script language="javascript" type="text/javascript">
// <!CDATA[

function TextArea1_onclick() {

}

// ]]>
</script>
</head>
<body style="vertical-align: middle; text-align: center" bgcolor="#cc3300">

<form id="frmNav" runat="server">
    <br />
    <asp:Label ID="Label1" runat="server" Height="40px" Text="Switchboard to run ASP.NET from SQL Server 2000" Width="248px" style="border-right: teal thin groove; border-top: teal thin groove; font-weight: bold; vertical-align: middle; border-left: teal thin groove; color: #ff0000; border-bottom: teal thin groove; text-align: center" BackColor="#E0E0E0"></asp:Label><br />
    <br />
    <br />

<asp:DropDownList id="ddlLocations" runat="server" BackColor="#E0E0E0" style="font-weight: bolder; color: red" />

<asp:Button id="btnGo" runat="server"
    Text = "Go"
    OnClick = "btnGo_Click"
/>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />

</form>

</body>
</html>

  Code for secondary page:
     <%@ Page Language="VB" Debug = "true"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>CA Table</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="1" class="ex" width="100%">
            <tr>
                <td>
                    <pre>
&nbsp;<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#CCCCCC"
    BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2"
    DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."
    ForeColor="Black">
    <FooterStyle BackColor="#CCCCCC" />
    <Columns>
        <asp:BoundField DataField="EIAC" HeaderText="EIAC" SortExpression="EIAC" />
        <asp:BoundField DataField="LCN" HeaderText="LCN" SortExpression="LCN" />
        <asp:BoundField DataField="ALC" HeaderText="ALC" SortExpression="ALC" />
        <asp:BoundField DataField="LTY" HeaderText="LTY" SortExpression="LTY" />
        <asp:BoundField DataField="TASK" HeaderText="TASK" SortExpression="TASK" />
        <asp:BoundField DataField="REF_EIAC" HeaderText="REF_EIAC" SortExpression="REF_EIAC" />
        <asp:BoundField DataField="REF_LCN" HeaderText="REF_LCN" SortExpression="REF_LCN" />
        <asp:BoundField DataField="REF_ALC" HeaderText="REF_ALC" SortExpression="REF_ALC" />
        <asp:BoundField DataField="REF_LTY" HeaderText="REF_LTY" SortExpression="REF_LTY" />
        <asp:BoundField DataField="REF_TASK" HeaderText="REF_TASK" SortExpression="REF_TASK" />
        <asp:BoundField DataField="AOR_LCN" HeaderText="AOR_LCN" SortExpression="AOR_LCN" />
        <asp:BoundField DataField="AOR_ALC" HeaderText="AOR_ALC" SortExpression="AOR_ALC" />
        <asp:BoundField DataField="AOR_LTY" HeaderText="AOR_LTY" SortExpression="AOR_LTY" />
        <asp:BoundField DataField="AOR_MB" HeaderText="AOR_MB" SortExpression="AOR_MB" />
        <asp:BoundField DataField="IDENT" HeaderText="IDENT" SortExpression="IDENT" />
        <asp:BoundField DataField="FREQ" HeaderText="FREQ" SortExpression="FREQ" />
        <asp:BoundField DataField="CC" HeaderText="CC" SortExpression="CC" />
        <asp:BoundField DataField="HCP" HeaderText="HCP" SortExpression="HCP" />
        <asp:BoundField DataField="HMPC" HeaderText="HMPC" SortExpression="HMPC" />
        <asp:BoundField DataField="PMCS" HeaderText="PMCS" SortExpression="PMCS" />
        <asp:BoundField DataField="MMET" HeaderText="MMET" SortExpression="MMET" />
        <asp:BoundField DataField="PMET" HeaderText="PMET" SortExpression="PMET" />
        <asp:BoundField DataField="MMMH" HeaderText="MMMH" SortExpression="MMMH" />
        <asp:BoundField DataField="PMMH" HeaderText="PMMH" SortExpression="PMMH" />
        <asp:BoundField DataField="PMD" HeaderText="PMD" SortExpression="PMD" />
        <asp:BoundField DataField="SMD" HeaderText="SMD" SortExpression="SMD" />
        <asp:BoundField DataField="FRC" HeaderText="FRC" SortExpression="FRC" />
        <asp:BoundField DataField="TERC" HeaderText="TERC" SortExpression="TERC" />
        <asp:BoundField DataField="TRT" HeaderText="TRT" SortExpression="TRT" />
        <asp:BoundField DataField="TLR" HeaderText="TLR" SortExpression="TLR" />
        <asp:BoundField DataField="TR" HeaderText="TR" SortExpression="TR" />
        <asp:BoundField DataField="TRC" HeaderText="TRC" SortExpression="TRC" />
        <asp:BoundField DataField="TPSA" HeaderText="TPSA" SortExpression="TPSA" />
        <asp:BoundField DataField="TPSB" HeaderText="TPSB" SortExpression="TPSB" />
        <asp:BoundField DataField="TPSC" HeaderText="TPSC" SortExpression="TPSC" />
        <asp:BoundField DataField="TCA" HeaderText="TCA" SortExpression="TCA" />
        <asp:BoundField DataField="TCB" HeaderText="TCB" SortExpression="TCB" />
        <asp:BoundField DataField="TCC" HeaderText="TCC" SortExpression="TCC" />
        <asp:CheckBoxField DataField="Baselined" HeaderText="Baselined" SortExpression="Baselined" />
        <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
    </Columns>
    <RowStyle BackColor="White" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:upsizedCandidateConnectionString 1 %>"
    ProviderName="<%$ ConnectionStrings:upsizedCandidateConnectionString 1.ProviderName %>"
    SelectCommand="SELECT [EIAC], [LCN], [ALC], [LTY], [TASK], [REF_EIAC], [REF_LCN], [REF_ALC], [REF_LTY], [REF_TASK], [AOR_LCN], [AOR_ALC], [AOR_LTY], [AOR_MB], [IDENT], [FREQ], [CC], [HCP], [HMPC], [PMCS], [MMET], [PMET], [MMMH], [PMMH], [PMD], [SMD], [FRC], [TERC], [TRT], [TLR], [TR], [TRC], [TPSA], [TPSB], [TPSC], [TCA], [TCB], [TCC], [Baselined], [Date] FROM [CA]">
</asp:SqlDataSource> </pre>
                </td>
            </tr>
        </table>

    </div>
    </form>
</body>
</html>

 
Old April 2nd, 2007, 08:40 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can you give us more detail about the way the files are organized? This sounds like a file, not a code problem.

-Peter
 
Old April 2nd, 2007, 08:55 AM
Authorized User
 
Join Date: Feb 2007
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to toddw607 Send a message via Yahoo to toddw607
Default

     The files are originally from SQL Server 2000. To create the ASP.NET files I opened the Server explorer and found the tables and dragged and dropped them onto the form of the .aspx page. It automatically created the web.config file.
     Also, the files are located on a server called mailserver and my folder is located in the path mailserver/Inetpub/wwwroot/tw/ . The web.config file is located under the wwwroot file and when I try to place one in the tw folder the initial page does not work while it does when I do not place it in the tw folder. But I am attempting to bring the .aspx pages up strictly through IE by placing the http in the address bar. Is that what you were asking for?

 
Old April 2nd, 2007, 09:07 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Let's try a different approach... Please reply with the following:

1) Url in the browser address bar when you have the page with the drop down list
2) Url in the browser address bar after you select a option from the list, and you get the 404 error.

Have you made the tw directory a virtual directory/application? This is critical for proper functioning of the web.config in it.

-Peter
 
Old April 2nd, 2007, 09:30 AM
Authorized User
 
Join Date: Feb 2007
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to toddw607 Send a message via Yahoo to toddw607
Default

I am running the pages on a local intranet connection and you will not be able to see them but here they are:
        1.)http://mailserver/tw/switchboard.aspx
        2.)http://mailserver/GenericErrorPage.h...ddsTable1.aspx

     I have not made the tw directory a virtual directory. THis should be done in IIS, under Admin Tasks, right? I have a shortcut to the server on my desktop and I tried to put that in and it says that the directory does not exist. I also tried to put the server directory in a it also said that it did not exist. these are the two paths I tried to tell IIS where the contenst where located:
1.) C:\Documents and Settings\twhitmarsh\Desktop\tw
2.) \\mailserver\Inetpub\wwwroot\tw

   Any thoughts?

 
Old April 2nd, 2007, 09:49 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If the tw directory is located in the server's wwwroot (which it appears to be) you should only need to browse to it in the IIS management console. Drill down thru the default web site until you get to it. then right-click, properties. On the "Directory" tab, check that "Application Name:" under "Application Settings" is greyed out and the button to the right is labeled with "Create". Click it. It's now a application and will obey the web.config settings.

It looks like the page name is ok from the DDL. It should be redirecting alright. But it sounds like the URL that it's trying to redirect to is not correct.

-Peter
 
Old April 2nd, 2007, 10:05 AM
Authorized User
 
Join Date: Feb 2007
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to toddw607 Send a message via Yahoo to toddw607
Default

I have the default website set to a virtual directory for the directory to my folder. The application has already been created. I have also tried putting in the entire URL for the main program to link to, nothing seems to be working. At least the problem is seeming to be narrowing down. I think I need to place a web.Config is my folder on the server but when I do the intial page does not display. Any suggestions?

 
Old April 2nd, 2007, 10:17 AM
Authorized User
 
Join Date: Feb 2007
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to toddw607 Send a message via Yahoo to toddw607
Default

Interesting....
    I removed the web.Config file in the wwwroot folder and placed it into the tw folder and now the initial page works but the links still are not working but it gives me a different error:


  Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

    This is what my web.Config file looks like:
  <?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
  <appSettings/>
  <connectionStrings>
    <add name="upsizedCandidateConnectionString1" connectionString="Data Source=SQLSERVER;Initial Catalog=upsizedCandidate;Integrated Security=True"
        providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions
            where data loss can occur.
            Set explicit="true" to force declaration of all variables.
        -->
    <compilation debug="false" strict="false" explicit="true" />
    <pages>
      <namespaces>
        <clear />
        <add namespace="System" />
        <add namespace="System.Collections" />
        <add namespace="System.Collections.Specialized" />
        <add namespace="System.Configuration" />
        <add namespace="System.Text" />
        <add namespace="System.Text.RegularExpressions" />
        <add namespace="System.Web" />
        <add namespace="System.Web.Caching" />
        <add namespace="System.Web.SessionState" />
        <add namespace="System.Web.Security" />
        <add namespace="System.Web.Profile" />
        <add namespace="System.Web.UI" />
        <add namespace="System.Web.UI.WebControls" />
        <add namespace="System.Web.UI.WebControls.WebParts" />
        <add namespace="System.Web.UI.HtmlControls" />
      </namespaces>
    </pages>
    <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
    <authentication mode="Windows" />
    <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.
   -->
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
              <error statusCode="403" redirect="NoAccess.htm" />
              <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>

          </system.web>
</configuration>


    Any thoughts?

 
Old April 2nd, 2007, 10:45 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Change "RemoteOnly" to "Off" in the custom errors node. Then you can see what the error is.

-Peter
 
Old April 2nd, 2007, 10:50 AM
Authorized User
 
Join Date: Feb 2007
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to toddw607 Send a message via Yahoo to toddw607
Default

My new error is:
   Line 52: ASP.NET to identify an incoming user.
Line 53: -->
Line 54: <authentication mode="Windows" />
Line 55: <!--
Line 56: The <customErrors> section enables configuration

    I am using Windows authentication do coincide with my system login. And I've changed ti in IIS as well but I still get the error.






Similar Threads
Thread Thread Starter Forum Replies Last Post
web.config problem in FileShare trieuanhl BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 November 2nd, 2008 09:48 AM
Web.Config problem darkestangel1980 ASP.NET 1.0 and 1.1 Basics 1 July 2nd, 2007 06:31 AM
problem in web.config chandanbhakuni ADO.NET 2 September 22nd, 2006 07:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.