Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
Server Error in '/' Application.

The view 'ReportViewer' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/ViewReport/ReportViewer.aspx
~/Views/ViewReport/ReportViewer.ascx
~/Views/Shared/ReportViewer.aspx
~/Views/Shared/ReportViewer.ascx
~/Views/ViewReport/ReportViewer.cshtml
~/Views/ViewReport/ReportViewer.vbhtml
~/Views/Shared/ReportViewer.cshtml
~/Views/Shared/ReportViewer.vbhtml

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The view 'ReportViewer' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/ViewReport/ReportViewer.aspx
~/Views/ViewReport/ReportViewer.ascx
~/Views/Shared/ReportViewer.aspx
~/Views/Shared/ReportViewer.ascx
~/Views/ViewReport/ReportViewer.cshtml
~/Views/ViewReport/ReportViewer.vbhtml
~/Views/Shared/ReportViewer.cshtml
~/Views/Shared/ReportViewer.vbhtml

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[InvalidOperationException: The view 'ReportViewer' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/ViewReport/ReportViewer.aspx
~/Views/ViewReport/ReportViewer.ascx
~/Views/Shared/ReportViewer.aspx
~/Views/Shared/ReportViewer.ascx
~/Views/ViewReport/ReportViewer.cshtml
~/Views/ViewReport/ReportViewer.vbhtml
~/Views/Shared/ReportViewer.cshtml
~/Views/Shared/ReportViewer.vbhtml]
   System.Web.Mvc.ViewResult.FindView(ControllerContext context) +506
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +230
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +321
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9651188
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34209

########################################################################
Yeah! that generate a link!
That is


using System;<pre lang="c#">
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.Reporting.WebForms;
using Newtonsoft.Json.Linq;
using GlobalPOS_WEBAPI_SERVICE.Models;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using Newtonsoft.Json;
using System.IO;
using System.Net;
using System.Net.Http.Headers;
using System.Web.Http.Cors;

namespace GlobalPOS_WEBAPI_SERVICE.Controllers
{
    public class ViewReportController : Controller
    {
      ///  private const string LocalReportName = "App_Data/Reports/Products.rdlc";
 
        public ActionResult ReportViewer(string projectname, string controllername, string functionname, string ReportType, string ReportName )
        {
         
            string JSONdataStream = new StreamReader(Request.InputStream).ReadToEnd();

            var re = Request;
            int CustomerID = 0;
            int userlevelid = 0;
            dynamic paramObj = new JObject();
            string reportParam = "";
            dynamic objResponse = new JObject();
            System.Collections.Specialized.NameValueCollection param = HttpContext.Request.Params;// System.Web.HttpUtility.ParseQueryString(qstr);
            string responseType = param.Get("responseType");
            dynamic objRequest = new JObject();
            objRequest.RequestProject = projectname;
            objRequest.RequestAction = functionname;
            objRequest.RequestController = controllername;
            objRequest.ResponseType = responseType;
            objRequest.RequestReportType = ReportType;
            objRequest.RequestReportName = ReportName;
            
     
            objRequest.RequestParams = "";

         
            if (re.Headers["userLevelID"] != null)
            {
                if (re.Headers["customerID"] != null)
                {
                    CustomerID =  Convert.ToInt32(re.Headers.GetValues("customerID").First());
                }
             userlevelid =   Convert.ToInt32( re.Headers.GetValues("userLevelID").First());
            }
            //bool IsParaNull = false;
            if (JSONdataStream != null)
            {

                objRequest.RequestParams =JSONdataStream;
                paramObj = JsonConvert.DeserializeObject(objRequest.RequestParams.Value);
                if (paramObj["reportParam"] != null)
                {
                    reportParam = paramObj["reportParam"].Value;
                }
               
                //System.Collections.Specialized.NameValueCollection postedParam = objRequest.RequestParams.Value;
                //reportParam = postedParam.Get("reportParam");
            }


            //DataTable dt = GLOBALEMS_WEBAPI_SERVICE.ReportGenerator.GenerateDT(IsParaNull, objRequest, CustomerID);
          

            string Report = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Report\\RDLC\\");
            Report += objRequest.RequestReportName + ".rdlc";
            System.Configuration.AppSettingsReader confReader = new System.Configuration.AppSettingsReader();
            string servicePath = confReader.GetValue("serviceRptURL", typeof(string)).ToString();
            var model = new LocalReportsModel
            {
               reportViewURL=servicePath +"ReportView.aspx",
                localReportPath = Report,
                localCustomerID=CustomerID,
                localUserLevelID=userlevelid,
              
                queryJSONString = JsonConvert.SerializeObject(objRequest),
               reportParameters = reportParam
            };

            return View(model);
        }
    }
}
Posted
Updated 9-Jul-15 19:21pm
v4
Comments
F-ES Sitecore 9-Jul-15 6:53am    
You are generating a link that is invalid or doing a redirect to a url that is invalid. As we don't have access to your code it's impossible to tell. If this is the result of clicking a link, post the code that generates the link. If it is as the result of a redirect post the code that does the redirect.
Wathon Aung 10-Jul-15 2:43am    
Pls,help me!
F-ES Sitecore 10-Jul-15 3:37am    
When you do this

return View(model);

from a function called "ReportViewer" in a class called "ViewReportController" then the mvc framework expects you to have a view (a cshtml file) at this location

/Views/ViewReport/ReportViewer.cshtml

however you don't. If you want to return a different view you need to specify the path to that view

return View("~/Views/..../MyView.cshtml", model);

if you aren't returning html but want to return your model as json then

return Json(model)

instead
Dharmesh .S. Patil 9-Jul-15 7:44am    
Modify your question.
Wathon Aung 10-Jul-15 3:56am    
I have 500 internal server occur! Why?
----------------------------------------
POST http://localhost:2000/ViewReport/ReportViewer/BLGeneral/BLGeneral.Stock.StockController/GetAllStockList/Stock/rpt_StockSummary 500 (Internal Server Error)

1 solution

I think that your problem may be that you don't have a route set up to the action on your controller:
C#
public ActionResult ReportViewer(string projectname, string controllername, string functionname, string ReportType, string ReportName)

For this to work, you would need to have a route set up in your RouteConfig.cs file, e.g.
C#
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute("{controller}/{action}/{projectname}/{controllername}/{functionname}/{ReportType}/{ReportName}",
        new RouteValueDictionary(new { controller = "ViewReport", action = "ReportViewer" }));
}

And the link that you're generating in your CSHTML file would need to include those parameters in the same order.

Alternatively, you may want to consider removing some of the parameters in your action (perhaps just pass one parameter in, e.g. some kind of report identifier)?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900