0

I have a MVC4 app that is using a ReportViewer control on a aspx page inside a iframe in my razor view. I followed this answer here: https://stackoverflow.com/a/11055132/876511.

Well this worked ok on localhost but it doesn't when i deploy to server.

First error i got was solved by setting the "Copy Local" property to true of the Microsoft.ReportViewer.WebForms Reference.

Than I got this error on server: "Could not load file or assembly 'Microsoft.ReportViewer.Common". For that i manually copied the dll from "C:\windows\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\11.0.0.0__89845dcd8080cc91" to the bin directory on server.

But now i'm getting this error that i can't figure it out:

[Win32Exception (0x80004005): The network path was not found]

[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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)] System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +414
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +167
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +143
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry) +83 System.Data.SqlClient.SqlConnection.Open() +96
System.Web.SessionState.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval) +110

[HttpException (0x80004005): Unable to connect to SQL Server session database.]
System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection conn, Exception e) +235
System.Web.SessionState.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval) +944
System.Web.SessionState.SqlSessionStateStore.GetConnection(String id, Boolean& usePooling) +231
System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +199
System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +798
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

What network path? The SQL Server? The rest of the app gets there fine.

Please help me, i have been stuck here for a few days and have no more ideias.

EDIT:

Found out where the error is. In my web.config.release i have this:

<sessionState mode="SQLServer" sqlConnectionString="Data Source=SQLSERVER;User ID=ASPState;Password=XXXXXXX" timeout="120" xdt:Transform="Replace"/>

When i comment out the reportViewer works, otherwise it gives network error. Somethings wrong, probably with the conn string, not sure what.

EDIT2: Conn string is fine otherwise would not work on the intire app.

My new guess is because its a mix of MVC and Webforms... The mvc connects ok to the sessionstate server but my webform doesnt. Why?

4

1 回答 1

0

尝试

ReportViewerRSFReports.ProcessingMode = ProcessingMode.Remote;
ReportViewerRSFReports.ServerReport.ReportServerCredentials = new CustomReportCredentials("user", "pass", "domain");
ReportViewerRSFReports.ServerReport.ReportServerUrl = new Uri("http://<Server Name>/ReportServer");
ReportViewerRSFReports.ServerReport.ReportPath = "/MYAPP/test";
ReportViewerRSFReports.ServerReport.Refresh();

替换reportserver.mydomain为您的 ReportServer。

对于 vaoid 错误,我通常在报告部署期间从 BID 输出窗口获取报告服务器 url 和报告路径。

于 2013-07-05T13:17:39.453 回答