Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible web.Config problem 1

Status
Not open for further replies.

toddw607

Programmer
Joined
Apr 2, 2007
Messages
55
Location
US
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" "
<script runat="server">

</script>

<html xmlns=" >
<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:upsizedCandidateConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:upsizedCandidateConnectionString1.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>
 
have you confirmed the value returned from the dropdown list is the the webpage you want to redirect to?

If so try placing the full url in the response.redirect() instead of only the page name. example: [tt]http://[domain]/[directory...]/CA.aspx[/tt] instead of just [tt]CA.aspx[/tt].

Also, try using the redirect overload.
Code:
Response.Redirect(ddlLocations.SelectedItem.Value, true)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I tried both of those and it's still giving me an error. Is there a simple way that I can access the secondary .aspx pages without using the dropdown list? Pretty much all i want is to view tables from SQL Server 2000 in Internet Explorer using asp. I already have the tables in .aspx stored on a server but when I type in the full path of the pages on the server it will not let me access them. Any way around this?
 
try using simple links and make sure they work.
Code:
<a href="CA.aspx">CA Page</a>
<a href="XH.aspx">XH Page</a>
<a href="ToddsTable1.aspx">Todd's Page</a>

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I placed the hrefs in my code and they work fine when I bring up the main page in VB but when I try to bring them up through the server by typing //mailserver/tw/switchboard , the links do not work. The dropdown box works just fine when it is brought up through VB but when I bring it up through the server the links do not work. I've even tried to include the entire path but no success. Any ideas?
 
toddw607 said:
works just fine when it is brought up through VB
what do your references to VB mean? Do you mean Visual Studio? Do you mean debugging the site on your local box the links work, but they don't work when you post the code to the server?

If so the issue is with IIS, virtual directories, and/or file permissions.


Jason Meckley
Programmer
Specialty Bakers, Inc.
 
but when I bring it up through the server the links do not work
Do you mean when you type the page directly into the browser's address bar?
 
Yes on both accounts. What could it be in the IIS? I've created a virtual directory but for some reason it is not working. Maybe I have to start all over in creating one?
 
What exactly are you typing into the address bar?
 
It may also be in the web.config file I was thinking
 
it says:
Server Error in '/' Application.
--------------------------------------------------------------------------------

Login failed for user 'DANDR\MAILSERVER$'.
Description: An unhandled exception occurred during the execution of the current web request

But I have everything set to Windows authorization
 
post your web.config and file structure (blank out username/passwords).

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
this is my file structure:
\\mailserver\Inetpub\
Here is my web.config:
<?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="Off" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>

</system.web>
</configuration>


Where the web.config file is placed in the folder and all the .aspx pages are in the tw folder. I tried to place them in the same folder but it would not work
 
ok, your authenticating users using Windows authentication, but your not authorizing user's access to the system, so any user (authenticated, or not) can visit any page.

your web.config file must be in the tw virtual directory. your file setup should look like this
[ul][li]\\mailserver\Inetpub\[ul] [li]\bin[ul][li]...list of assemblies[/li][/ul][/li]
[li]web.config[/li]
[li]CA.aspx[/li]
[li]XH.aspx[/li]
[li]ToddTable1.aspx[/li]
[li]switchboard.aspx[/li]
[/ul][/li][/ul]if you get access denied or unauthroized access, or prompted for a username/password set IIS to authenticate this virtual directory using Windows Authentiation. (right click directory, properties, security).

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks..I'll give that a shot...I will let you know how I make out.
 
I hvae it working on my personal machine but I cannot get it to work over the server. It is an SQL SERVER issue which works fine on my machine and works fine out of Visual Studio but when I try to access the links from my default page it throws up errors. For the first link I switched the name to come out of the server it is loacted on instead of my machine and it gives a much less error. I just cannot figure out how it could work fine on the server using VS but not by linking when I type the default (initial) web page into the address bar in Internet explorer. Mus be a SQL Server/IIS problem. I'll try to find some info and post anything that might help. If any one else has any ideas any help at all would be appreciated :-)
 
if you post the actual error(s) your receiving we may be able to help. there are so many possible errors that we are grabbing at straws without an error #, message or stack trace.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
This is the error I'm getting right now:
Server Error in '/' Application.
--------------------------------------------------------------------------------

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error:


Line 29: ASP.NET to identify an incoming user.
Line 30: -->
Line 31: <authentication mode="Windows"/>
Line 32: <!--
Line 33: The <customErrors> section enables configuration


Source File: c:\inetpub\ Line: 31


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42


If it may help here is my web.config file:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<add name="upsizedCandidateConnectionString1" connectionString="Data Source=SQLSERVER;Initial Catalog=upsizedCandidate;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="upsizedCandidateConnectionString" connectionString="Data Source=SQLSERVER;Initial Catalog=upsizedCandidate;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="false"/>
<authentication mode="Windows"/>
<customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
</system.web>
</configuration>


In IIS it is noted that .aspx is set up as an application so I'm not sure what is going wrong. THanks for taking a look!
 
This error can be caused by a virtual directory not being configured as an application in IIS.
That's your problem.

Open IIS on the server.
expand the tree down to you application directory.
right click, properties.
Virtual Directory Tab.
Application Settings. Click the button to create the virtual directory as an application.
click OK.
visit the website.

things should begin to work.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top