File not Found error on asp page

S

Steve Hoyer

I am trying to deploy my first asp.net app to our webserver (2K server,
IIS 5)

My start page comes up and you can get to the subsequent pages that are
tied into our sql server (2K). Each page has a datagrid that loads up
just fine, but when I click on any link that updates the page, i.e. a
column header to sort the database, it returns a 404 error.

Any ideas why it works the for the inital load and not on a postback?

Steve Hoyer
 
S

Steve Hoyer

Here seems to be the pertinent section of the log file. Note the
<Rejected-By-UrlScan> at the bottom.

192.168.1.102 - 192.168.1.211 80 GET /LFPAssisstant/LFPSHome.htm - 404
192.168.1.102 - 192.168.1.211 80 GET /LFPAssisstant/LFPSHome.html - 404
192.168.1.211 - 192.168.1.211 80 GET
/aspnet_client/system_web/1_1_4322/SmartNav.htm - 404
192.168.1.211 - 192.168.1.211 80 GET
/aspnet_client/system_web/1_1_4322/SmartNav.js - 404
192.168.1.102 - 192.168.1.211 80 GET /LFPAssisstant/LFPAHome.htm - 200
192.168.1.102 - 192.168.1.211 80 GET /LFPAssisstant/frmRegister.aspx -
200
192.168.1.102 - 192.168.1.211 80 GET
/aspnet_client/system_web/1_1_4322/SmartNav.htm - 404
192.168.1.102 - 192.168.1.211 80 GET
/aspnet_client/system_web/1_1_4322/SmartNav.js - 404
192.168.1.102 - 192.168.1.211 80 GET /<Rejected-By-UrlScan>
~/LFPAssisstant/frmRegister.aspx 404


Steve Hoyer
 
S

Steve Hoyer

Unfortunatly, as is the way with these things, the code runs superbly
<grin> on my development machine. I am trying deploy it as my first
asp.net application and on the live server is the bombing.

I apologize for the length of this message, but if you ask for code, you
get code :)

Anyway, here is the HTML:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="frmSessions.aspx.vb"
Inherits="LakeFrontParkAssisstant.frmSessions"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>frmSessions</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<A href="LFPAHome.htm">Go Home!</A>
<form id="Form1" method="post" runat="server">
<table cols="3" align="left">
<tr>
<td align="left" colSpan="3"><asp:label id="lblPageHeader"
runat="server" Font-Size="Large">Session
Maintenance</asp:label></THEAD></td>
</tr>
<tr>
<td align="left" colSpan="3"><asp:datagrid id="dgSessions"
runat="server" Font-Size="Small" AutoGenerateColumns="False"
AllowPaging="True"
PageSize="6" AllowSorting="True" BackColor="White"
Font-Names="Arial" HorizontalAlign="Left" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical" ShowFooter="True">
<SelectedItemStyle Font-Size="Small" Font-Names="Arial"
Font-Bold="True" HorizontalAlign="Left" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>
<EditItemStyle Font-Size="Small" Font-Names="Arial"
HorizontalAlign="Left" ForeColor="Black"
BackColor="Aquamarine"></EditItemStyle>
<AlternatingItemStyle Font-Size="Small" Font-Names="Arial"
HorizontalAlign="Left" BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle Font-Size="Small" Font-Names="Arial"
HorizontalAlign="Left" ForeColor="Black"
BackColor="#EEEEEE"></ItemStyle>
<HeaderStyle Font-Size="Medium" Font-Names="Arial"
Font-Bold="True" HorizontalAlign="Left" ForeColor="White"
BackColor="#000084"></HeaderStyle>
<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
<Columns>
<asp:ButtonColumn Text="Insert"
CommandName="Insert"></asp:ButtonColumn>
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn Visible="False" DataField="sessionid"
SortExpression="sessionid" HeaderText="Session ID"></asp:BoundColumn>
<asp:BoundColumn DataField="sessionname"
SortExpression="sessionname" HeaderText="Session
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="begindate"
SortExpression="begindate" HeaderText="Begin Date"
DataFormatString="{0:MM-dd-yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="enddate" SortExpression="enddate"
HeaderText="End Date"
DataFormatString="{0:MM-dd-yyyy}"></asp:BoundColumn>
</Columns>
<PagerStyle ForeColor="Black" BackColor="#999999"
Mode="NumericPages"></PagerStyle>
</asp:datagrid></td>
</tr>
<tr>
<td align="left" colSpan="3"><asp:label id="lblWhatsUp"
style="Z-INDEX: 101" runat="server" Font-Size="Medium"></asp:label></td>
</tr>
<tr>
<td align="left"><asp:label id="lblSessionName" style="Z-INDEX:
110" runat="server">Session Name:</asp:label></td>
<td align="left"><asp:label id="lblBeginDate" style="Z-INDEX: 111"
runat="server">Begin Date:</asp:label></td>
<td align="left"><asp:label id="lblEndDate" style="Z-INDEX: 113"
runat="server">End Date:</asp:label></td>
</tr>
<tr>
<td align="left"><asp:textbox id="txtSessionName" style="Z-INDEX:
102" runat="server"></asp:textbox></td>
<td align="left"><asp:textbox id="txtBeginDate" style="Z-INDEX:
103" runat="server"></asp:textbox></td>
<td align="left"><asp:textbox id="txtEndDate" style="Z-INDEX: 104"
runat="server"></asp:textbox></td>
</tr>
<tr>
<td align="left" colSpan="3"><asp:button id="btnDo"
runat="server"></asp:button></td>
</tr>
<tr>
<td align="left" colSpan="3"><asp:label id="lblSessionID"
style="Z-INDEX: 106" runat="server"
Visible="False"></asp:label><asp:label id="lblSQLWhere" style="Z-INDEX:
109" runat="server" Visible="False"></asp:label><asp:label
id="lblSQLSortCol" style="Z-INDEX: 107" runat="server"
Visible="False">sessionid</asp:label><asp:label id="lblSQLSortDir"
runat="server" Visible="False">ASC</asp:label></td>
</tr>
</table>
</form>
</body>
</HTML>


Followed by the code behind:

Public Class frmSessions
Inherits System.Web.UI.Page
Protected conString As New
SqlClient.SqlConnection("user=myuser;password=mypassword;server=myserver
;database=mydatabase")
Protected SQLStmt As String
Protected SQLSort As String
Protected SQLWhere As String

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents dgSessions As
System.Web.UI.WebControls.DataGrid
Protected WithEvents txtEndDate As System.Web.UI.WebControls.TextBox
Protected WithEvents lblWhatsUp As System.Web.UI.WebControls.Label
Protected WithEvents lblSessionID As System.Web.UI.WebControls.Label
Protected WithEvents lblSQLSortCol As
System.Web.UI.WebControls.Label
Protected WithEvents lblSQLSortDir As
System.Web.UI.WebControls.Label
Protected WithEvents lblSQLWhere As System.Web.UI.WebControls.Label
Protected WithEvents lblSessionName As
System.Web.UI.WebControls.Label
Protected WithEvents lblBeginDate As System.Web.UI.WebControls.Label
Protected WithEvents lblEndDate As System.Web.UI.WebControls.Label
Protected WithEvents txtBeginDate As
System.Web.UI.WebControls.TextBox
Protected WithEvents txtSessionName As
System.Web.UI.WebControls.TextBox
Protected WithEvents btnDo As System.Web.UI.WebControls.Button
Protected WithEvents lblPageHeader As
System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

SQLStmt = "SELECT sessionid, sessionname, begindate, enddate
FROM lfp_sessions"
SQLSort = " ORDER BY " & lblSQLSortCol.Text & " " &
lblSQLSortDir.Text
SQLWhere = ""

If Not Page.IsPostBack Then
BindData()
End If

'setup gui
GUI("Hide")

End Sub

#Region " Data Grid Events "

Private Sub dgSessions_ItemCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgSessions.ItemCommand
'e.Item is the row of the table where the button was clicked.

Try
'choose button type
Select Case e.CommandName
Case Is = "Sort"
Case Is = "Select"
Case Is = "Insert"
GUI("Clear")
lblWhatsUp.Text = "Adding Item: "
LoadTextBoxes(e)
btnDo.Text = "Insert Record"
GUI("Show")
Case Is = "Edit"
Case Is = "Delete"
Case Is = "Page"
End Select
Catch Exc As Exception
'Process exception and return.
'Dim log As System.Diagnostics.EventLog = New
System.Diagnostics.EventLog
'log.Source = "My Application"
'log.WriteEntry(Exc.ToString())
'Console.WriteLine("Exception of type {0} occurred.",
exc.GetType().ToString())
Finally
End Try
End Sub

Private Sub dgSessions_DeleteCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgSessions.DeleteCommand
GUI("Clear")
lblWhatsUp.Text = "Deleting Item: "
lblSessionID.Text = e.Item.Cells(3).Text
LoadTextBoxes(e)
btnDo.Text = "Delete Record"
GUI("Show")
End Sub

Private Sub dgSessions_EditCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgSessions.EditCommand
GUI("Clear")
lblWhatsUp.Text = "Editing Item: "
lblSessionID.Text = e.Item.Cells(3).Text
LoadTextBoxes(e)
btnDo.Text = "Submit Changes"
GUI("Show")
End Sub

Private Sub dgSessions_PageIndexChanged(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
Handles dgSessions.PageIndexChanged
GUI("Clear")
dgSessions.CurrentPageIndex = e.NewPageIndex
BindData()
End Sub

Private Sub dgSessions_SortCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles
dgSessions.SortCommand
If lblSQLSortCol.Text = e.SortExpression Then
Select Case lblSQLSortDir.Text
Case Is = "ASC"
lblSQLSortDir.Text = "DESC"
Case Is = "DESC"
lblSQLSortDir.Text = "ASC"
End Select
Else
lblSQLSortCol.Text = e.SortExpression
lblSQLSortDir.Text = "ASC"
End If
SQLSort = " ORDER BY " & lblSQLSortCol.Text & " " &
lblSQLSortDir.Text
BindData()
End Sub

#End Region

#Region " Data Handling "

Sub BindData()
Dim myDataAdapter As SqlClient.SqlDataAdapter
Dim myDataSet As New DataSet

Try
myDataAdapter = New SqlClient.SqlDataAdapter(SQLStmt &
SQLWhere & SQLSort, conString)
myDataAdapter.Fill(myDataSet, "lfp_sessions")
Dim dv As New DataView
dv = myDataSet.Tables("lfp_sessions").DefaultView
dgSessions.DataSource = dv
dgSessions.DataBind()
Catch Exc As System.OverflowException
Finally
End Try
End Sub

Sub DeleteData()
Dim myDataAdapter As SqlClient.SqlDataAdapter
Dim myDataSet As New DataSet

Try
myDataAdapter = New SqlClient.SqlDataAdapter(SQLStmt &
SQLWhere & SQLSort, conString)
myDataAdapter.Fill(myDataSet, "lfp_sessions")

myDataAdapter.DeleteCommand = New
SqlClient.SqlCommand("DELETE FROM lfp_sessions WHERE (sessionid =
@Original_sessionid)", conString)
myDataAdapter.DeleteCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@original_sessionid",
System.Data.SqlDbType.Int, 4)).Value = lblSessionID.Text

myDataSet.Tables(0).AcceptChanges()
Dim myDataRow As DataRow = myDataSet.Tables(0).Rows(0)
myDataRow.Delete()
myDataAdapter.Update(myDataSet.Tables(0))

Catch Exc As System.OverflowException
Finally
End Try
End Sub

Sub EditData()
Dim myDataAdapter As SqlClient.SqlDataAdapter
Dim myDataSet As New DataSet

Try
myDataAdapter = New SqlClient.SqlDataAdapter(SQLStmt &
SQLWhere & SQLSort, conString)
myDataAdapter.Fill(myDataSet, "lfp_sessions")

myDataAdapter.UpdateCommand = New
SqlClient.SqlCommand("UPDATE lfp_sessions SET sessionname =
@sessionname, begindate = @begindate, enddate = @enddate WHERE
(sessionid = @Original_sessionid)", conString)
myDataAdapter.UpdateCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@original_sessionid",
System.Data.SqlDbType.Int, 4)).Value = lblSessionID.Text
myDataAdapter.UpdateCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sessionname",
System.Data.SqlDbType.VarChar, 50, "sessionname"))
myDataAdapter.UpdateCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@begindate",
System.Data.SqlDbType.DateTime, 8, "begindate"))
myDataAdapter.UpdateCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@enddate",
System.Data.SqlDbType.DateTime, 8, "enddate"))

myDataSet.Tables(0).AcceptChanges()
Dim myDataRow As DataRow = myDataSet.Tables(0).Rows(0)
myDataRow = FillRow(myDataRow)
myDataAdapter.Update(myDataSet.Tables(0))

Catch Exc As System.OverflowException
Finally
End Try
End Sub

Sub InsertData()
Dim myDataAdapter As SqlClient.SqlDataAdapter
Dim myDataSet As New DataSet

Try
myDataAdapter = New SqlClient.SqlDataAdapter(SQLStmt,
conString)
myDataAdapter.Fill(myDataSet, "lfp_sessions")

myDataAdapter.InsertCommand = New
SqlClient.SqlCommand("INSERT INTO lfp_sessions(sessionname, begindate,
enddate) VALUES (@sessionname, @begindate, @enddate)")

myDataAdapter.InsertCommand.Connection = conString
myDataAdapter.InsertCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sessionname",
System.Data.SqlDbType.VarChar, 50, "sessionname"))
myDataAdapter.InsertCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@begindate",
System.Data.SqlDbType.DateTime, 8, "begindate"))
myDataAdapter.InsertCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@enddate",
System.Data.SqlDbType.DateTime, 8, "enddate"))

Dim myDataRow As DataRow = myDataSet.Tables(0).NewRow()
myDataRow = FillRow(myDataRow)
myDataSet.Tables(0).Rows.Add(myDataRow)
myDataAdapter.Update(myDataSet.Tables(0))

Catch Exc As System.OverflowException
Finally
End Try
End Sub

Function FillRow(ByVal dr As DataRow)
dr("sessionname") = txtSessionName.Text
dr("begindate") = txtBeginDate.Text
dr("enddate") = txtEndDate.Text
Return dr
End Function

#End Region

Private Sub btnDo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDo.Click

Try
Dim SQLTemp As String = SQLWhere
Select Case btnDo.Text
Case Is = "Insert Record"
SQLWhere = " WHERE sessionid = '" &
lblSessionID.Text & "'"
InsertData()
SQLWhere = SQLTemp
BindData()
Case Is = "Submit Changes"
SQLWhere = " WHERE sessionid = '" &
lblSessionID.Text & "'"
EditData()
SQLWhere = SQLTemp
BindData()
Case Is = "Delete Record"
SQLWhere = " WHERE sessionid = '" &
lblSessionID.Text & "'"
DeleteData()
SQLWhere = SQLTemp
If dgSessions.CurrentPageIndex >=
(dgSessions.PageCount - 1) Then
dgSessions.CurrentPageIndex = 0
BindData()
dgSessions.CurrentPageIndex =
(dgSessions.PageCount - 1)
End If
BindData()
End Select
Catch Exc As System.OverflowException

Finally
'handle GUI
GUI("Hide")
GUI("Clear")
End Try
End Sub

Private Sub GUI(ByVal strAction As String)
Try
Select Case strAction
Case Is = "Hide"
lblWhatsUp.Visible = False
lblSessionName.Visible = False
txtSessionName.Visible = False
txtBeginDate.Visible = False
lblBeginDate.Visible = False
txtEndDate.Visible = False
lblEndDate.Visible = False
btnDo.Visible = False
Case Is = "Show"
lblWhatsUp.Visible = True
lblSessionName.Visible = True
txtSessionName.Visible = True
lblBeginDate.Visible = True
txtBeginDate.Visible = True
lblEndDate.Visible = True
txtEndDate.Visible = True
btnDo.Visible = True
Case Is = "Clear"
lblWhatsUp.Text = ""
lblSessionID.Text = ""
txtSessionName.Text = ""
txtBeginDate.Text = ""
txtEndDate.Text = ""
btnDo.Text = ""
End Select
Catch Exc As System.OverflowException
Finally
End Try

End Sub

Private Sub LoadTextBoxes(ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs)

If e.Item.Cells(4).Text <> "&nbsp;" Then txtSessionName.Text =
e.Item.Cells(4).Text
If e.Item.Cells(5).Text <> "&nbsp;" Then txtBeginDate.Text =
e.Item.Cells(5).Text
If e.Item.Cells(6).Text <> "&nbsp;" Then txtEndDate.Text =
e.Item.Cells(6).Text

End Sub
End Class




Steve Hoyer
 
R

Raterus

What does the source of the html page once its rendered look like? Something on it is telling your browser to go to another page on the site. Make sure your form is posting back to itself. Let me know what you find.

--Michael
 
S

Steve Hoyer

Would it have anything to do with have the SmartNavigation enabled on
the form?

Steve Hoyer
 
R

Raterus

Could very well be, turn it off and see for yourself. I do hear smartnavigation can be buggy though, and only works on IE.
 
P

Patrice

Likely caused by the ~ character. AFAIK this is a server side notation that
is not handled by IIS itself...

Note also that you have also some other elements that are not found...

Patrice
 
S

Steve Hoyer

I apologize - smart navigation is not enabled on this particular form
(though it is on others, and as this is a purely internal application -
other browsers are not a problem - but good to keep in mind)

The ~ character does not show up in my code anywhere - only in the log.
As for the other 404's, I just did another test to see what my log had
to say if I made sure of my routine. So no 404's this time, but same
problem.

It said:

2004-05-26 14:08:01 192.168.1.211 - 192.168.1.211 80 GET
/LFPAssisstant/LFPAHome.htm - 304
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.0.3705;+.N
ET+CLR+1.1.4322)

2004-05-26 14:08:09 192.168.1.211 - 192.168.1.211 80 GET
/LFPAssisstant/frmSessions.aspx - 200
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.0.3705;+.N
ET+CLR+1.1.4322)

2004-05-26 14:08:15 192.168.1.211 - 192.168.1.211 80 GET
/<Rejected-By-UrlScan> ~/LFPAssisstant/frmSessions.aspx 404
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.0.3705;+.N
ET+CLR+1.1.4322)

btw - Patrice, what does AFAIK stand for?

Steve Hoyer
 
P

Patrice

AFAIK is for "As Far As I Know".

Ok, it looks like anyway that UrlSCan comes in play to reject this request.
I would try then (assuming this is not too risky) to disable UrlScan to see
what happens.

If it works, it's very likely some UrlScan setting that doesn't like this
request (POST verb unintentionaly disabled ? but probably something less
obvious)

Patrice
 
S

Steve Hoyer

I tried uninstalling and reinstalling the IIS Lockdown tool, making sure
I had asp selected as my template. This didn't work, but did produce a
different error of:

Invalid PInvoke metadata format

After trying other things that didn't work (removing and rereferencing
system.data, etc), I found that I did have the .net framework installed
twice on my live webserver (versions 1.0 and 1.1). I uninstalled both,
and reinstalled 1.1, and voila, problem solved.

Now, onto getting crystal reports working :(

Thanks for all the responses. They were greatly appreciated.

Steve Hoyer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top