无法通过http GETrequest访问SQL Server数据库

时间:2012-08-13 22:31:00

标签: jquery asp.net sql-server json webmatrix

我试图从Windows Server 2008 r2上运行的我的SQL Server数据库中获取一些作为Json对象返回的行,但是我收到500内部服务器错误有人可以帮我解决这个问题吗?以下是一些更多信息。

开发环境:WebMartrix 2

代码:

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

}

以下是响应错误消息:

  

警告:您已在此页面上多次添加Google Maps API。这可能会导致意外错误   {main,places} .js(第42行)
  获得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)
-->

1 个答案:

答案 0 :(得分:0)

IIS使用的用户帐户没有足够的权限来读取/写入数据库。

更改IIS应用程序池设置中使用的用户帐户,或将用户帐户IIS AppPool / nopowervi.com配置为具有从数据库中读取所需的权限。

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