954,123 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Why app is looking for "Default.aspx"

Hi,

I am new to ASP.NET, working on a web app using Visual Studio and VB. My App was working fine before and after I made few changes, It opens "Default.aspx" for any selection. I've even remaned the file "default.aspx" in the solution to something else and made sure there is no reference to "default.aspx" page in my code, it still looks for it and app fails with error that "default.aspx" not found. I am very frustated, please help !! :confused:

thanks in advance.
T

Texpert
Newbie Poster
14 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 

Which version of VS are you using? Is the app hosted in IIS? Have you made changes there? What "Changes" did you make just before it stopped working?

Something is set in VS i think to make it start up looking for default.aspx but need to know which VS you are using first

f1 fan
Posting Whiz in Training
279 posts since Jan 2006
Reputation Points: 26
Solved Threads: 11
 

Which version of VS are you using? Is the app hosted in IIS? Have you made changes there? What "Changes" did you make just before it stopped working?

Something is set in VS i think to make it start up looking for default.aspx but need to know which VS you are using first


Thanks for the reply. I am using VS 2003 Ver 7.1.3088 and I did not change anything in IIS settings.
Attaching my code.
the app starts with page "Home.aspx" and from there it opens "login.aspx" where depending on the login and role of the person it should open perticular page, which was working fine, now it is looking for "default.aspx" always. the chnage I made was just to add "Session("Homepage_selection") super cookie in there.

webconfig
<?xml version="1.0" encoding="utf-8" ?>
.web>

Home.aspx.vb
Public Class WebForm8
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()

End Sub
Protected WithEvents CoachActivity As System.Web.UI.WebControls.Label
Protected WithEvents GLC As System.Web.UI.WebControls.Label
Protected WithEvents LinkButton_Colleagues As System.Web.UI.WebControls.LinkButton
Protected WithEvents LinkButton_Managers As System.Web.UI.WebControls.LinkButton
Protected WithEvents LinkButton_Coaches As System.Web.UI.WebControls.LinkButton
Protected WithEvents LinkButton_Admin As System.Web.UI.WebControls.LinkButton
Protected WithEvents TopLine As System.Web.UI.WebControls.Label
Protected WithEvents BottomLine As System.Web.UI.WebControls.Label
Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton

'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
'Put user code to initialize the page here
End Sub

Private Sub LinkButton_Colleagues_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton_Colleagues.Click
Session("HomePage_Selection") = "Colleague" ' colleague
Response.Redirect("Login.aspx")
End Sub

Private Sub LinkButton_Managers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton_Managers.Click
Session("HomePage_Selection") = "Manager" 'Manager
Response.Redirect("Login.aspx")

End Sub

Private Sub LinkButton_Coaches_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton_Coaches.Click
Session("HomePage_Selection") = "Coach" 'Coach
Response.Redirect("Login.aspx")

End Sub

Private Sub LinkButton_Admin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton_Admin.Click
Session("HomePage_Selection") = "Admin" 'Administrator
Response.Redirect("Login.aspx")

End Sub

Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Session("HomePage_Selection") = "Guest" 'Guest
Response.Redirect("Login.aspx")
End Sub
End Class

Login.aspx.vb
Imports System.Data.SqlClient
Imports System.Web.Security

Public Class Login_form
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()

End Sub
Protected WithEvents GLC As System.Web.UI.WebControls.Label
Protected WithEvents CoachLoginForm As System.Web.UI.WebControls.Label
Protected WithEvents PlEnter As System.Web.UI.WebControls.Label
Protected WithEvents Username As System.Web.UI.WebControls.Label
Protected WithEvents Password As System.Web.UI.WebControls.Label
Protected WithEvents BottomLine As System.Web.UI.WebControls.Label
Protected WithEvents Coach_Pass As System.Web.UI.WebControls.TextBox
Protected WithEvents Error_Message As System.Web.UI.WebControls.Label
Protected WithEvents cmdSubmit As System.Web.UI.WebControls.Button
Protected WithEvents UserId As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents LinkBtn_Guest As System.Web.UI.WebControls.LinkButton
Protected WithEvents LinkBtn_Register As System.Web.UI.WebControls.LinkButton
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents TopLine As System.Web.UI.WebControls.Label
Protected WithEvents Btn_Back As System.Web.UI.WebControls.Button

'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
'Put user code to initialize the page here
'Error_Message.Text = "I am here"
End Sub

Private Function ValidateUser(ByVal userName As String, ByVal passWord As String) As String
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim returnUser_role As String

returnUser_role = Nothing

Error_Message.Text = "I am in the function"

Try
Error_Message.Text = "I am here 1"
conn = New SqlConnection("server=localhost;Integrated Security=SSPI;database=Coaching")
conn.Open()
cmd = New SqlCommand("Select Role_Key from Logins where login=@userName and passwd=@passWord", conn)

cmd.Parameters.Add("@userName", SqlDbType.Char, 50)
cmd.Parameters("@userName").Value = userName
cmd.Parameters.Add("@passWord", SqlDbType.Char, 50)
cmd.Parameters("@passWord").Value = passWord

returnUser_role = cmd.ExecuteScalar()

cmd.Dispose()
conn.Dispose()

If (returnUser_role Is Nothing) Then
returnUser_role = "invalid"
Return returnUser_role
End If

If (Session("HomePage_Selection") <> returnUser_role) Then
returnUser_role = "Invalid"
Error_Message.Text = "For the Selected Role"
Return returnUser_role
End If

'Error_Message.Text = "For the Selected Role" & returnUser_role

Return returnUser_role

Catch ex As Exception
System.Diagnostics.Trace.WriteLine("[ValidateUser] Exception " & ex.Message)
End Try

End Function
Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
Dim Coach_role As String

Coach_role = Nothing
Error_Message.Text = "I am in the Sub this -->" & Coach_role

If Page.IsValid Then
Coach_role = (ValidateUser(UserId.Text.Trim(), Coach_Pass.Text.Trim())).Trim
Error_Message.Text = "I am this -->" & Coach_role

FormsAuthentication.RedirectFromLoginPage(UserId.Text, False)


If (Coach_role = "Invalid") Then
Error_Message.Text = "Err : Invalid Username / Password" & Error_Message.Text
If CInt(Session("Num_of_Tries")) > 2 Then
Response.Redirect("Denied.aspx")
End If
ElseIf (Coach_role = "Colleague") Then
Response.Redirect("TL_SelectionPage.aspx")
ElseIf (Coach_role = "Manager") Then
Response.Redirect("TL_SelectionPage.aspx")
ElseIf (Coach_role = "Coach") Then
Response.Redirect("Add_Coach.aspx")
ElseIf (Coach_role = "Admin") Then
'Response.Redirect("Admin_SelectionPage.aspx")
ElseIf (Coach_role = "Guest") Then
Response.Redirect("CoachFinder.aspx")
Else
Error_Message.Text = "Err : Invalid Username / Password" & Error_Message.Text
End If


End If
End Sub

Private Sub Btn_Back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Back.Click
Response.Redirect("Home.aspx")
End Sub

Private Sub LinkBtn_Guest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkBtn_Guest.Click
If Page.IsValid Then
UserId.Text = "Guest"
Coach_Pass.Text = "Guest"

FormsAuthentication.RedirectFromLoginPage(UserId.Text, False)
Response.Redirect("CoachFinder.aspx")
End If
End Sub

Private Sub LinkBtn_Register_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkBtn_Register.Click

End Sub
End Class
==========================

thanks again.
T :!:

Texpert
Newbie Poster
14 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 

I have a feeling that something has set iis to look for default.aspx as the start page, or vs has been told to do the same. Did you have a default.aspx in there at one time? in your solution explorer right click on your home.aspx and click on set as start page. That will make sure that vs is correct. if you just opened a web browser and typed in the path there does it still happen? (I assume you have tried this).
Couple of other pointers outside of this. why are you using windows authentication and then implementing a login box and roles in a sql database? that usually implies forms authentication. Also, my vb is rusty at best and it may be more forgiving than c# but in c# you have to cast anything from the session before using it, otherwise it is just an object type and your <> wouldnt work.

f1 fan
Posting Whiz in Training
279 posts since Jan 2006
Reputation Points: 26
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You