मेरे पास SQL2005 रिपोर्टिंग सर्वर पर एक रिपोर्ट सहेजी गई है, और मैं इस रिपोर्ट के एक प्रस्तुत पीडीएफ को वापस करना चाहता हूं। स्थानीय * .rdlc फ़ाइल (and I've blogged about it) के साथ काम करते समय मैंने यह पता लगाया है, लेकिन जब * .rdl एक रिपोर्टिंग सर्वर पर रहता है। मैं लाइन पर एक 401 अधिकृत नहीं त्रुटि हो रही है ...एसएसआरएस रिपोर्ट व्यूअर + एएसपी.नेट प्रमाण पत्र 401 अपवाद
reportViewer.ServerReport.SetParameters(reportDefinition.ReportParameters);
यहाँ रिपोर्ट प्रस्तुत करने के लिए इस्तेमाल किया विधि है।
public byte[] Render(IReportDefinition reportDefinition)
{
var reportViewer = new ReportViewer();
byte[] renderedReport;
try
{
var credentials = new WindowsImpersonationCredentials();
reportViewer.ServerReport.ReportServerUrl = new Uri("http://myssrsbox", UrlKind.Absolute);
reportViewer.ServerReport.ReportServerCredentials = credentials;
reportViewer.ServerReport.ReportPath = reportDefinition.Path;
// Exception is thrown on the following line...
reportViewer.ServerReport.SetParameters(reportDefinition.ReportParameters);
string mimeType;
string encoding;
string filenameExtension;
string[] streams;
Warning[] warnings;
renderedReport = reportViewer.ServerReport.Render(reportDefinition.OutputType, reportDefinition.DeviceInfo, out mimeType, out encoding, out filenameExtension, out streams, out warnings);
}
catch (Exception ex)
{
// log the error...
throw;
}
finally
{
reportViewer.Dispose();
}
return renderedReport;
}
दूसरी बात यह है कि आप भूल रहे हैं WindowsImpersonationCredentials वर्ग है।
public class WindowsImpersonationCredentials : IReportServerCredentials
{
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = password = authority = null;
return false;
}
public WindowsIdentity ImpersonationUser
{
get { return WindowsIdentity.GetCurrent(); }
}
public ICredentials NetworkCredentials
{
get { return null; }
}
public override string ToString()
{
return String.Format("WindowsIdentity: {0} ({1})", this.ImpersonationUser.Name, this.ImpersonationUser.User.Value);
}
}
अन्य चीजें आप को पता है की आवश्यकता हो सकती ...
- यह किसी इंट्रानेट पर प्रतिरूपण चल रहा है, और चालू है।
- लॉगिंग इंगित करता है कि प्रतिरूपण उपयोगकर्ता सही ढंग से सेट किया जा रहा है।
- यह काम करता है जब दृश्य स्टूडियो (
http://localhost:devport
) में चल रहा है, और यह काम करता है जब मेरे विकास बॉक्स (http://localhost/myApplication
) पर चल रहा है। यह हमारे परीक्षण या उत्पादन सर्वर पर चलते समय काम नहीं करता है। - मैंने web.config में system.net.defaultProxy सेटिंग्स के साथ और बिना दोनों समाधानों का प्रयास किया है। न तो काम किया।
मैं क्या गलत कर रहा हूं? क्या यह एक सर्वर सेटिंग है? क्या यह कोड है? क्या यह web.config है?
प्रतिरूपण उपयोगकर्ता रिपोर्ट सर्वर तक पहुँच है - विशेष रूप से उस रिपोर्ट? – NYSystemsAnalyst
क्या आपने अपने डीवी मशीन (लोकलहोस्ट) पर प्रतिरूपण उपयोगकर्ता के तहत आईआईएस चलाने का प्रयास किया है ताकि आपके परीक्षण सर्वर पर क्या हो रहा है? यह रिपोर्टिंग सर्वर या रिपोर्टिंग सर्वर डेटाबेस के विरुद्ध आपके प्रतिरूपण उपयोगकर्ता के साथ एक फ्लैट आउट अनुमतियों की तरह लगता है। मुझे लगता है कि प्रतिरूपण उपयोगकर्ता एक डोमेन खाता है। –
@NYSystems विश्लेषक - हां, प्रतिरूपण उपयोगकर्ता को रिपोर्ट सर्वर पर उपयुक्त निर्देशिका तक पहुंच है। –