2012-08-13 54 views
0

我想從我的SQL Server數據庫在Windows Server 2008 R2上運行的SQL Server數據庫中獲取一些JSON對象返回的行,但我收到了500內部服務器錯誤,任何人都可以請幫助我解決這個問題?以下是一些更多信息。無法通過http GETrequest訪問SQL Server數據庫

開發環境:WebMartrix 2

代碼:

@{ 
    var result = MyDataBase.GetData(); 
    Response.ContentType = "application/json"; 
    Json.Write(result, Response.Output); 

} 

這裏是響應錯誤消息:

警告:你已經包括此頁面上的谷歌地圖API多次。這可能會導致意外的錯誤。
{主,地點}的.js(線42)
GET http://nopowervi.com/Pages/GetReports/
500內部服務器錯誤
577ms
JQuery的-1.7.2.js(第4行)
HeadersResponseHTML

<html> 
<head> 
<title>Login failed for user 'IIS APPPOOL\nopowervi.com'.</title> 
<style> 
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} 
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} 
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } 
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } 
pre {font-family:"Lucida Console";font-size: .9em} 
.marker {font-weight: bold; color: black;text-decoration: none;} 
.version {color: gray;} 
.error {margin-bottom: 10px;} 
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } 
</style> 
</head> 
<body bgcolor="white"> 
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> 
<h2> <i>Login failed for user 'IIS APPPOOL\nopowervi.com'.</i> </h2></span> 
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> 
<b> Description: </b>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. 
<br><br> 
<b> Exception Details: </b>System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\nopowervi.com'.<br><br> 
<b>Source Error:</b> <br><br> 
<table width=100% bgcolor="#ffffcc"> 
<tr> 
<td> 
<code><pre> 
Line 1: @{ 
<font color=red>Line 2: var result = MyDataBase.GetData(); 
</font>Line 3: Response.ContentType = &quot;application/json&quot;; 
Line 4: //Json.Write(result.OrderByDescending(d =&gt; d.Time), Response.Output);</pre></code> 
</td> 
</tr> 
</table> 
<br> 
<b> Source File: </b> c:\inetpub\nopowervi.com\Pages\GetReports.cshtml<b> &nbsp;&nbsp; Line: </b> 2 
<br><br> 
<b>Stack Trace:</b> <br><br> 
<table width=100% bgcolor="#ffffcc"> 
<tr> 
<td> 
<code><pre> 
[SqlException (0x80131904): Login failed for user &#39;IIS APPPOOL\nopowervi.com&#39;.] 
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +6317296 
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412 
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2660 
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53 
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +6337726 
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6337705 
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +352 
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +831 
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +49 
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +6339510 
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +78 
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +2194 
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +89 
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6343022 
System.Data.SqlClient.SqlConnection.Open() +300 
WebMatrix.Data.Database.EnsureConnectionOpen() +115 
WebMatrix.Data.&lt;QueryInternal&gt;d__0.MoveNext() +79 
System.Collections.Generic.List'1..ctor(IEnumerable'1 collection) +472 
System.Linq.Enumerable.ToList(IEnumerable'1 source) +80 
WebMatrix.Data.Database.Query(String commandText, Object[] parameters) +140 
ASP._Page_Pages_GetReports_cshtml.Execute() in c:\inetpub\nopowervi.com\Pages\GetReports.cshtml:2 
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280 
System.Web.WebPages.WebPage.ExecutePageHierarchy() +372 
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +181 
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +232 
</pre></code> 
</td> 
</tr> 
</table> 
<br> 
<hr width=100% size=1 color=silver> 
<b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET a 
</font> 
</body> 
</html> 
<!-- 
[SqlException]: Login failed for user &#39;IIS APPPOOL\nopowervi.com&#39;. 
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) 
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) 
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) 
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) 
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) 
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) 
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) 
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) 
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) 
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) 
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) 
at System.Data.SqlClient.SqlConnection.Open() 
at WebMatrix.Data.Database.EnsureConnectionOpen() 
at WebMatrix.Data.Database.<QueryInternal>d__0.MoveNext() 
at System.Collections.Generic.List'1..ctor(IEnumerable'1 collection) 
at System.Linq.Enumerable.ToList[TSource](IEnumerable'1 source) 
at WebMatrix.Data.Database.Query(String commandText, Object[] parameters) 
at ASP._Page_Pages_GetReports_cshtml.Execute() in c:\inetpub\nopowervi.com\Pages\GetReports.cshtml:line 2 
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 
at System.Web.WebPages.WebPage.ExecutePageHierarchy() 
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) 
at System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) 
[HttpUnhandledException]: Exception of type &#39;System.Web.HttpUnhandledException&#39; was thrown. 
at System.Web.WebPages.WebPageHttpHandler.HandleError(Exception e) 
at System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) 
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 
--> 

回答

0

IIS使用的用戶帳戶沒有足夠的權限來讀取/寫入數據庫。

要麼更改IIS應用程序池設置中使用的用戶帳戶,要麼將用戶帳戶IIS AppPool/nopowervi.com配置爲具有從數據庫讀取所需的權限。

此鏈接可能會有所幫助:http://technet.microsoft.com/en-us/library/cc771170(v=ws.10).aspx

相關問題