Wednesday, March 7, 2012

HELP! - URL Access - Localhost vs. ServerName

We have a confusing problem and need some guidance.

We are trying to use URL access to generate and display a report. We have tried two ways--building the URL string and popping up a new browser with the Reporting Services URL access string and simply using an anchor tag and setting its URL parameter to the Reporting Services URL access string. Both options don't work--well, one works for the local server and the other works for client computers (not the server), but neither work for both.

Basically, we're having trouble using localhost vs. servername in our URL access string.

The examples below use localhost.
These work fine from the server which Reporting Services and IIS are running, but not from other computers (because of the "localhost").
// Build the URL for the report
url = "http://localhost/ReportServer?/Reports/MyReport&rs:Command=Render&rs:format=HTML4.0&rc:Parameters=false&rc:Zoom=Page Width";
// Build the javascript to display the message
string sScript = "<script language=\"javascript\" type=\"text/javascript\">window.open(\"" + url + "\", \"ReportsDateSelectionGenerateReport\", \"height=675,width=975,left=0,top=0,copyHistory=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no\");</script>";
// Execute the script
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "LinkButtonGenerateReport_Click", sScript);


<a id="runreport" runat="server" target="_blank" style="font-size: large; font-weight: bold;">View Report</a>
this.runreport.HRef = "http://localhost/ReportServer?/Reports/MyReport&rs:Command=Render&rs:format=HTML4.0&rc:Parameters=false&rc:Zoom=Page Width";


The examples below use the servername for URL access.
These work fine from other computers (because of the server name), but I get the Connect to <servername> popup asking for User name and Password when I run from the server which Reporting Services and IIS are running.
// Build the URL for the report
url = "http://" + <servername> + "/ReportServer?/Reports/MyReport&rs:Command=Render&rs:format=HTML4.0&rc:Parameters=false&rc:Zoom=Page Width";
// Build the javascript to display the message
string sScript = "<script language=\"javascript\" type=\"text/javascript\">window.open(\"" + url + "\", \"ReportsDateSelectionGenerateReport\", \"height=675,width=975,left=0,top=0,copyHistory=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no\");</script>";
// Execute the script
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "LinkButtonGenerateReport_Click", sScript);


<a id="runreport" runat="server" target="_blank" style="font-size: large; font-weight: bold;">View Report</a>
this.runreport.HRef = "http://" + <servername> + "/ReportServer?/Reports/MyReport&rs:Command=Render&rs:format=HTML4.0&rc:Parameters=false&rc:Zoom=Page Width";

I guess the main issue is using the servername in the URL access string pops up the connect to server dialog wanting a user name and password, even though we're trying to access the report on the server running Reporting Services and IIS. We're using Windows Authentication and impersonation (in our Web.config file), and we're logged into the server as local Administrator. Therefore, we should have no permissions issues.

How can we use the servername in URL access for both the server and client workstation to generate and display reports?

Thanks in advance.

That is very strange. You should be able to subsitute the server name for localhost on the server. Do you get this same behavior when you try this form IE?

How do you get <servername>? Is it possibly getting the wrong value when on the local machine?

|||

Well, I'm always using IE. We don't support other browsers (our ASP.NET 2.0 (C#) application is an intranet application and end-users are required to use IE).

And, yes, we get the same behavior if we copy and paste the entire URL string into the browser's Address bar. It's the same thing as if we were running it through our app's code.

It seems kind of wierd to us too. It seems that if you're working on the server, using the server name should work fine (just like using "localhost").

By the way, we're working on a Win 2003 server with SP1 and using SQL Server 2005 Reporting Services. I read somewhere that the security settings in Win 2003 might be causing such an issue.

As for the servername, we're getting it using a .NET method (I can't remember right now). But, we've definitely tested this and are getting the correct server name from both the server and workstation.

So, we're stumped. Any ideas?

Thanks!

|||

Is there any other .NET Framework class with a property or method that would tell whether the request is coming from a different computer or if the request is coming from the server itself?

Then I could say:

if (coming from workstation computer--not the server == true)
{
// use http://servername/ReportServer...
}
else if (coming from a browser on the server == true)
{
// use http://localhost/ReportServer...
}

Any thoughts?

|||

You could always check the request IP address, but that would be masking the issue rather then fixing the cause.

Have you tried to repro this via your own web app? My guess this is more of an IIS configuration issue then an RS issue. I will have one of our other devs look over this thread and see if he has any other suggestions.

No comments:

Post a Comment