#12003/11/20 23:27:28
我在自己的机子测试成功了,但上传服务器为什么会出现如下:
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.
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".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
错误呢?
文件夹外面的web.config文件:
<configuration>
<system.web>
<compilation debug="true"/>
<customErrors mode="Off"/>
</system.web>
</configuration>
login.aspx文件:
<%@ Import Namespace="System.Web.Security " %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<Html>
<Body>
<Form runat="server">
请先登入您的帐号及密码:
<Blockquote>
帐号:<asp:TextBox runat="server" id="Account" />
密码:<asp:TextBox runat="server" id="Password"
TextMode="Password" />
记住密码:<asp:CheckBox runat="server" id="RememberMe" />
<asp:Button runat="server" text="登入" onClick="Login_Click" />
<asp:Label runat="server" id="Msg" ForeColor="Red" />
</Blockquote>
<Font Size=-1 Color=Blue>登入网页前, 请确定浏览器的 Cookie 是开启的.</Font>
</Form>
</Body>
</Html>
<script language="VB" runat="server">
Sub Login_Click( sender As Object, e As EventArgs )
If Verify( Account.Text, Password.Text ) Then
FormsAuthentication.RedirectFromLoginPage(Account.Text, RememberMe.Checked)
Else
Msg.Text = "帐号或密码错误, 请重新输入!"
End If
End Sub
Function Verify( 帐号 As String, 密码 As String) As Boolean
Dim Conn As OleDbConnection, Cmd As OleDbCommand
Dim Rd As OleDbDataReader, SQL As String
Dim Provider = "Provider=Microsoft.Jet.OLEDB.4.0"
Dim Database = "Data Source=" & Server.MapPath( "Users.mdb" )
Conn = New OleDbConnection( Provider & ";" & DataBase )
Conn.Open()
SQL = "Select * From Users Where " & _
"UserID='" & 帐号 & "'" & _
" And Password='" & 密码 & "'"
Cmd = New OleDbCommand( SQL, Conn )
Rd = Cmd.ExecuteReader()
If Rd.Read() Then ' 表示有找到 UserID 及 Password, 通过验证
Conn.Close()
Return True
Else
Conn.Close()
Msg.Text = "帐号或密码错误, 请重新输入!"
Return False
End If
End Function
</script>
web.comfig文件:
<configuration>
<system.web>
<authentication mode="Forms">
<forms name="manage" loginUrl="Login.aspx" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>