|
Here is my code in the View, this is all I have, don't I have reference to ReportViewer added or some middle line in between the Controller Code is failing like Service Call etc which is making the ViewBag null, just not understanding, any help would be greatly helpful thanks my friend.
I just tested Report Path is also correct, I just put log and tested it, but the problem is, ReportPath is coming like this the Physical Path (C:\PIMS\Reports\LegalEntityReport.rdlc), this Physical Path is correct, I put the Virtual Path (full Path to report hard coded) also, in both cases it failed.
And another one I tested just now is that DataSet and DataTable both are not null values they have rows, so its not because I am passing null values, so it must be something related to setting in config etc.
I am not sure what's the reason for its failure, any config setting or etc, I don't know what it is, any help please
@using ReportViewerForMvc;
@{
ViewBag.Title = "Show Legal Entity Report";
Layout = "~/Views/Shared/_LayoutFinal.cshtml";
}
@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)
modified 15-Nov-18 17:19pm.
|
|
|
|
|
Using Value as Type will return null if the value cannot be converted to the type.
Try using a cast instead, just in case the value is of the wrong type:
@Html.ReportViewer((Microsoft.Reporting.WebForms.ReportViewer)ViewBag.ReportViewer)
If you still get a NullReferenceException , then you'll need to debug your code to make sure you're actually setting the ViewBag value.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry Richard, it didn't fix the problem yet, is it because of any security hitch because we are using SSL on the Server or am I missing any other dll etc, I have all the dlls added and deployed on the Server, is it because using ReportViewerForMVC itself is a problem? I have not seen much support about that tool also and I don't know using it with SSL is bad combination, or SSL itself is a problem.
I have put the ignore Certificates code as well in Global.asax file, still not working, or just the Physical Path itself is a problem, but the report Viewers that are used by the iFrame are working fine in other applications - those applications are also using the MapPath code means Physical Path, they are on the same Server too, I thought this also works and internally this tool also uses a .aspx page just like their approach but in iFrame approach the code to generate report is written in the .aspx pages Code behind but in the ReportViewerForMVC the report generation code is written in the Controller, but not understanding Richard, not logging any information also.
MapPath is returning Physical Path, is it because of that, is it because Local not Remote, just don't know Richard, very sad in ending up in this way. If anybody can help me who gone through the same situations please help me, I really really thankful to you.
Quote: If you still get a NullReferenceException, then you'll need to debug your code to make sure you're actually setting the ViewBag value.
How can I do it on the Server Richard, I am seeing the DataSet and DataTable are not null, I am not getting any information why is it failing, any help would be great for me Richard.
modified 16-Nov-18 13:49pm.
|
|
|
|
|
You're getting a NullReferenceException for the reportViewew parameter.
Either ViewBag.ReportViewer is null , or it is not an instance of the Microsoft.Reporting.WebForms.ReportViewer class.
If you can't work out how to debug it, then temporarily change your view to output the type of the value:
@using ReportViewerForMvc;
@{
ViewBag.Title = "Show Legal Entity Report";
Layout = "~/Views/Shared/_LayoutFinal.cshtml";
}
@* Comment out this line: *@
@* @Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer) *@
@if (ViewBag.ReportViewer == null)
{
<p>ReportViewer is not set!</p>
}
else if ((ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer) is null)
{
<p>ReportViewer is the wrong type: @ViewBag.ReportViewer.GetType()</p>
}
else
{
<p>Everything looks OK...</p>
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks a lot Richard.
I just saw it, ViewBag is not null hence it is displaying the text "Everything looks OK..." but, now its going to the home page of the application, is it because of the Path Problem or Security Problem not understanding. Just asking, can we put try catch in cshtml to catch an Exception if its raised and log it on a file or db or even at least JavaScript console is also fine or can I hard-code and assign a reports Virtual Path directly to the ReportViewer tool directly, then deploy and see if it is just the Path not being able to access. It seems like one of these two might be the problem clearly, any help my friend, please?
modified 16-Nov-18 14:10pm.
|
|
|
|
|
If you're getting "Everything looks OK", then you must be hitting an unknown bug in the ReportViewerForMvc library[^].
Make sure you're using the latest version. Triple-check that you've spelled the ViewBag.ReportViewer correctly in your view. If it still doesn't work, you'll have to raise an issue on GitHub[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hi Richard, yes you are very true, I changed the approach, I have used the iFrame approach I am getting the following error
An error occurred during local report processing.
The definition of the report 'C:\PIMS\Reports\LegalEntityReport.rdlc' is invalid.
An unexpected error occurred in Report Processing.
Could not load file or assembly 'Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
but the report is in the same path, is it something related to Path or any other library issue, can you please let me know, thanks a lot my friend.
|
|
|
|
|
You're missing the SQL Server spatial types assembly from your server.
You can download the installers from Microsoft and install them on the server:
Download Microsoft® SQL Server® 2012 Feature Pack from Official Microsoft Download Center[^]
(Links under Instructions ⇒ Microsoft® System CLR Types for Microsoft® SQL Server® 2012)
Or you can install v11 of the NuGet package[^], which will copy the files to your application so that you can copy them up to the server.
Install-Package Microsoft.SqlServer.Types -Version 11.0.0
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hurrayyyyyy !.... yes this fixed the problem, but still I don't understand why it didn't work with ReportViewerForMVC approach - just took lot of effort and stress my friend.
And thanks a lot for being with me, its great and absolutely great, you are awesome person - thanks a lot again.
|
|
|
|
|
hi Richard mate - one more thing I have identified, that ReportViewerForMVC is also working fine now, so was it the Microsoft.SqlServer.Types that was missing, if it is then why didn't the ReportViewerForMVC inform me in Exception or etc? Where as the iFrame approach has informed me so that I could able to fix the issue. It would have been easier if I would have known this dll that was missing, it left very bad impression around colleagues that it is simple and I am not able to fix the issue.
Thanks for helping me all the way along this issue mate. Hope you don't mind me calling you - mate 
modified 16-Nov-18 17:59pm.
|
|
|
|
|
simpledeveloper wrote: why didn't the ReportViewerForMVC inform me in Exception or etc?
Probably worth raising this as an issue on the GitHub project, so the developers can address it in a future release.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Can you please let me know website or some email where I can raise this issue my friend, yeah it is important it seems - thank you so much again.
|
|
|
|
|
|
Yes I did, thanks my friend, happy thanks giving
|
|
|
|
|
I am a beginner in vb.net and asp.net.
I have been researching and experimenting a few methods for this one week, none worked, most of the methods will only print one page (current page) in the crystal report.
Meanwhile, the default print button in the crystal report viewer has only the export option, in the pop menu that comes out when the button is clicked.
I want to have an external button in which when its clicked it opens the print preview page, displaying all pages of the report from the crystal report viewer, where the user can select the printer, adjust whatever settings, and choose the pages to be print.
IS THIS EVEN POSSIBLE? what would be the best method? please give me some example code. Thanks in advance
modified 21-Nov-18 2:59am.
|
|
|
|
|
|
Hi friends,
My WCF Service that's deployed is giving me the faulted Exception as below:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Loggedin User: DHSINTRA\AAleemMo
Error Message: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Error Source: mscorlib
Error InnerException Message:
Error TargetSite: Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
Error StackTrace:
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)
at DHCS.BH.Provider.WebApp.Common.WebAppLogger.LogError(String applicationName, String version, Exception exception, Nullable`1 dateTS, String appUsername, String nameSpace, String class, String method, Int32 enumPriority)
at DHCS.BH.Provider.WebApp.Filters.BHPRVAuthorizeAttribute.LoadUserAuthorizationDetails(AuthorizationContext filterContext, String userName)
at DHCS.BH.Provider.WebApp.Filters.BHPRVAuthorizeAttribute.OnAuthorization(AuthorizationContext filterContext)
at System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__0(AsyncCallback asyncCallback, Object asyncState)
Error Controller: LegalEntity
Error Action: ListLegalEntities
I read online, they are suggesting to implement the WCF Extension class, but I am not in a stage to change the whole process or architecture again, is there any other solution that can help me please or is it really failing because of the timeout, any help a code snippet, a link or even a suggestion helps me a lot - thanks in advance my friends.
|
|
|
|
|
this exception means that you have some thing wrong n the server side and you cant use this channel any more see this page
Help people,so poeple can help you.
|
|
|
|
|
Is there anyway how can I find what is the Problem that I am having on Server Side, because the exception doesn't give me any specific reason to fix the problem. Please any help would be great-full my friend - thanks in advance.
|
|
|
|
|
Hi, I am generating reports in my ASP.Net MVC Web application by using ReportViewerForMvc tool, I am able to generate them locally on my machine by using the code below.
public ActionResult ShowLegalEntityReport(string legalEntityNumber, string lENumOperator, string legalEntityName, string lENameOperator
, string taxId, string taxIdOperator, string submittingCounty, string submCountyOperator, string legalEntityCity, string lECityOperator)
{
ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.SizeToReportContent = true;
reportViewer.Width = Unit.Percentage(900);
reportViewer.Height = Unit.Percentage(900);
DataRetrieveServiceClient drsc = new DataRetrieveServiceClient();
DataTable dt = CommonFunctions.ToDataTable(drsc.GetLegalEntityReport(legalEntityNumber, lENumOperator, legalEntityName, lENameOperator, taxId, taxIdOperator
, submittingCounty, submCountyOperator, legalEntityCity, lECityOperator));
reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\LegalEntityReport.rdlc";
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("LegalEntityDataSet", dt));
ViewBag.ReportViewer = reportViewer;
return View();
}
To run it on the Server I have used the following change but the report generation fails locally as well on my machine:
reportViewer.LocalReport.ReportPath = Request.ApplicationPath + @"/Reports/LegalEntityReport.rdlc";
Any help would very greatly helpful, please need some help as it is urgent, thanks in advance.
|
|
|
|
|
Try:
reportViewer.LocalReport.ReportPath = Request.MapPath("~/Reports/LegalEntityReport.rdlc");
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
We have an IIS server that is hosting multiple web applications. Once in a blue moon the odd pool gets jammed up and needs to be manually recycled which means we currently have to RD into the server, open IIS - find the pool, right click etc.
We want to develop a web page that lists all the pools and allows us to click a recycle button.
Is that possible and if so does anyone know how to do it ?
Thanks
Mike
|
|
|
|
|
I just googled "programatically recycle iis app pool" and found the code in seconds. If you do the same you'll find lots of articles discussing this.
|
|
|
|
|
The following code will recycle the current site's app pool. You need to add a reference to Microsoft.Web.Administration
using (ServerManager iisManager = new ServerManager())
{
SiteCollection sites = iisManager.Sites;
foreach (Site site in sites)
{
if (site.Name == HostingEnvironment.ApplicationHost.GetSiteName())
{
iisManager.ApplicationPools[site.Applications["/"].ApplicationPoolName].Recycle();
break;
}
}
}
|
|
|
|
|
Thank you. We tried that and we have it working on a local PC server but when we move it to a regular Windows Server we get a permissions error. We have IIS_IUSRS full control and we still get the same error on the server. Are we missing some other sort of permission ?
We get this ................
Filename: redirection.config Error: Cannot read configuration file due to insufficient permissions
at Microsoft.Web.Administration.Interop.IAppHostAdminManager.GetAdminSection(String bstrSectionName, String bstrPath) at Microsoft.Web.Administration.Configuration.GetSectionInternal(ConfigurationSection section, String sectionPath, String locationPath) at Microsoft.Web.Administration.ServerManager.SitesSectionCreator() at Microsoft.Web.Administration.Lazy.Initialize[T](T& target, CreateInstanceDelegate`1 valueFactory) at Microsoft.Web.Administration.ServerManager.get_SitesSection() at Microsoft.Web.Administration.ServerManager.SitesCollectionCreator() at Microsoft.Web.Administration.Lazy.Initialize[T](T& target, CreateInstanceDelegate`1 valueFactory) at Microsoft.Web.Administration.ServerManager.get_Sites() at RefreshAppPool.Controllers.HomeController.GetApplicationPool()
|
|
|
|
|