2016-04-22 195 views
0

當我通過按F5在Visuall Studio中測試它,它工作正常,我可以登錄網頁和sql查詢過程很好地工作。另外請注意,我的SQL服務器通過Internet可以使用IP地址訪問。ASP.NET [Win32Exception(0x80004005):訪問被拒絕]錯誤

但是,當我在myasp.net託管服務提供商發佈我的ASP.Net網站,並且我得到的登錄屏幕很好地工作。但問題是,當我點擊登錄按鈕時,我得到了在VS中測試時發生的以下錯誤。

Server Error in '/' Application. Access is denied Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: Access is denied

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Win32Exception (0x80004005): Access is denied]

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - Access is denied.)]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +1005
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +799
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +726
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +85
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +449
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +108
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +942
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +143
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions) +17
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry) +139
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry) +367 System.Data.SqlClient.SqlConnection.Open() +129
UserLogin_VB.Login.ValidateUser(Object sender, EventArgs e) +220
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +109 System.Web.UI.WebControls.Login.AttemptLogin() +119
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +75 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +120
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +31 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3450

+0

檢查您的連接字符串,如果其正確,那麼它必須是防火牆問題。 –

+1

我不認爲你的提供者會允許你訪問這樣的私人SQL。如果是這種情況,您需要使用由您的asp.net提供程序託管和支持的sql。 – Asken

+0

@Dr。針4,SQL連接部分和防火牆是完美的,因爲我的基於Windows的EXE的工作正常,以相同的連接字符串在不同的位置通過連接sql服務器的IP地址。還有其他建議嗎? – Sixthsense

回答

-3

檢查你正在使用正確的登錄憑證在網絡配置文件,如果是的話,請給一個完全訪問網絡組

+0

網站位於遠程位置,服務器位於其他位置。他們不在同一個網絡上。 – Asken

+3

這應該是一個評論,它不回答這個問題 – nhouser9

0

Asken Quote:

I don't think your provider will allow you to access a private sql like that. If that's the case you'll need to use a sql that is hosted and supported by your asp.net provider.

@Asken 你說的沒錯...我收到了myasp.net客戶支持的以下回復。

Dear Customer,

Sorry, for performance reasons, we don't allow our customer to connect to remote database server. We suggest you simply make a backup of your database and restore it to our server to test your application. You’ll see a much faster performance and reliability using this method.

However, if you must connect to a remote database server, please consider upgrading to our Premium Plan or Semi Dedi Plan. Once you upgrade to these hosting plans, you can enable any ports your want in your Control Panel -> Security Manager -> Outgoing Port Manager.

And don't worry, we provide a 60 days FULL Money Back for all of our plans.

Thank you.