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?

Community
  • 1
  • 1
Fraposo
  • 107
  • 1
  • 3
  • 9

1 Answers1

0

try

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();

Replace reportserver.mydomain with your ReportServer.

To a vaoid errors, i normally get the report server url and report path from BID out put windows during report deployment.

StackTrace
  • 9,190
  • 36
  • 114
  • 202
  • It doesn't work either. The error occurs before these lines. Its trying to connect to something before i set the reportserver. I tried not set at all the server and still get the same error on deply server and diferente error on localhost – Fraposo Jul 05 '13 at 13:48