Monday, March 12, 2012

Works on Local but not on web hosting server

Works on Local machine but not on web hosting server, any ideas why?

<%@dotnet.itags.org. Page Language="VB" Trace="false" %>
<%@dotnet.itags.org. import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load
Dim actionstr as String

If User.Identity.ISAuthenticated = "false" then
If not Request.QueryString("action") = "login" then
Response.Redirect("Corefile.aspx?action=login")
end if
end if

Trace.Write( "User.Identity.ISAuthenticated = " & User.Identity.ISAuthenticated )

End Sub


Sub Button2_Click(sender As Object, e As EventArgs)

FormsAuthentication.SignOut
Response.Redirect("Corefile.aspx?action=login")

End Sub



Function Authenticated(username As String, password As String) As Boolean
Dim dbconnection As Sqlconnection
Dim getuserID as Sqlcommand
Dim userID as SqlDataReader

dbconnection = New SqlConnection( "Server=888;uid=commline;pwd=88;database=88" )
dbconnection.open()

getuserID = New sqlcommand( "Select u_id FROM Userfile WHERE u_username = '" & Microsoft.Visualbasic.Lcase(txtuser.text) & "' AND u_password = '" & Microsoft.Visualbasic.Lcase(txtpass.text) & "'", dbconnection )
userID = getuserID.ExecuteReader()

If userID.HasRows then

While userID.Read()

Return True

End While

Else

Return False

End if

userID.close()
dbconnection.close()

End Function

Sub Button1_Click(sender As Object, e As EventArgs)
If Authenticated(txtuser.text,txtpass.text) then

Dim ticket as New FormsAuthenticationTicket( txtuser.text, checkbox1.checked, 10 )
Dim encTicket As String = FormsAuthentication.Encrypt(ticket)
Response.Cookies.Add(New HttpCookie(FormsAuthentication.FormsCookieName,encticket))
Response.Redirect("Corefile.aspx?action=summary")
else

Label1.text = "Bad username or Password"

end if
End Sub

</script>
<% Select Case Request.QueryString("action") %><% Case "login" %>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<font face="Trebuchet MS" size="5"><strong>CLIENT LOGIN</strong></font>
</p>
<p>
<font size="2"><font face="Trebuchet MS">Username:</font>
<br />
</font>
<asp:TextBox id="txtuser" runat="server"></asp:TextBox>
</p>
<p>
<font face="Trebuchet MS" size="2">Password:</font>
<br />
<asp:TextBox id="txtpass" runat="server"></asp:TextBox>
</p>
<p>
<asp:CheckBox id="CheckBox1" runat="server" Text="Remember me with Cookies?"></asp:CheckBox>
<br />
<br />
<asp:Label id="Label1" runat="server" font-bold="True" forecolor="Red" font-size="X-Small" font-names="Trebuchet MS" width="227px">Welcome
to Client Login</asp:Label>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Login" Width="72px"></asp:Button>
</p>
<!-- Insert content here -->
</form>
<p>
<% Case "summary" %>

User.Identity.IsAuthenticated = <% Response.write ( User.Identity.ISAuthenticated ) %> <p>
<form runat="server">
<asp:Button id="Button2" onclick="Button2_Click" runat="server" Text="Log Out" Width="72px"></asp:Button>
</form>

<% Case Else %>

What do you want?

<% End Select %>
</p>
</body>
</html>

<configuration>
<system.web>
<customErrors mode="Off"/>
<appSettings>
<authentication mode="Forms">
<forms
name=".ASPXAUTH"
loginUrl="corefile.aspx?action=login"
protection="All"
timeout="80"
path="/"/>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>How exactly doesn't it work on the web hosting server? ie. some fucntions don't work, page doesn't load at all.

Are you given an error message?
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.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
Can you put
<customErrors mode="Off" />

in your web.config file then, and then see what error you get?
done, but same error
The only time i've had that happen is when there has been a fault on the host.

Nothing i'm sure about here but a few idea's...
1. Are both development machine and hosting server running same version of asp.net framework?
2. Have you uploaded all the correct files to the web server?

if i think of anything else i'll get back to you,

Good luck.

0 comments:

Post a Comment