I've got the traditional website with all MVC 5 working as expected, everything renders correctly and works fine.
I've added a Dashboard and this dashboard I am attempting to set to folder structure up to where it is isolated from the rest of the MVC 5 C# website; however, I'm receiving a Server Error stating that the layout engine cannot find my Partial views.
Now, when the view itself loads this is passing the test and is indeed returning the correct view, the problem is coming in when the layout engine cannot locate the nested Partial Views.
I am lost on this one due to the fact that I do not have a MVC 5 full understanding.
Now, like mentioned before everything works perfectly in regards to the out of the box folder structure but when I create a nested folder and put Partial Views the MVC 5 engine cannot locate these nested Partial Views.
The reason being nesting these Partial Views is obvious I am separating the actual traditional website from the User Dashboard views.
When I click the action link pointing to the Index file this works but when the body, The View, trys to render it cannot find the nested Partial Views.
What am I missing here? I hope that I am providing enough information that make answering this question as easy as possible.
Loading the Actual User Dashboard Index Works
#{
ViewBag.Title = "Your Dashboard";
Layout = "~/Views/Shared/UserDashboard/_Layout_Dashboard.cshtml";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
Loading the actual Partials is where the Server says NO NO, you're not doing this correctly.
Here is the Exact Server Error, Please Advise Me On The Proper Way to Implement this.
Server Error in '/' Application.
The partial view '~/Views/Shared/UserDashboard/_PartialHeader_Dashboard' was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Shared/UserDashboard/_PartialHeader_Dashboard
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 partial view '~/Views/Shared/UserDashboard/_PartialHeader_Dashboard' was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Shared/UserDashboard/_PartialHeader_Dashboard
Source Error:
Line 26: <script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>*#
Line 27: <body>
Line 28: #Html.Partial("~/Views/Shared/UserDashboard/_PartialHeader_Dashboard")
Line 29: #Html.Partial("~/Views/Shared/UserDashboard/_PartialLeftNav_Dashboard")
Line 30: #RenderBody()
Source File: D:\Users\Erik\Documents\visual studio 2017\Projects\BuilderBits\BuilderBits\Views\Shared\UserDashboard\_Layout_Dashboard.cshtml Line: 28
Stack Trace:
[InvalidOperationException: The partial view '~/Views/Shared/UserDashboard/_PartialHeader_Dashboard' was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Shared/UserDashboard/_PartialHeader_Dashboard]
System.Web.Mvc.HtmlHelper.FindPartialView(ViewContext viewContext, String partialViewName, ViewEngineCollection viewEngineCollection) +327
System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +264
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +91
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName) +32
ASP._Page_Views_Shared_UserDashboard__Layout_Dashboard_cshtml.Execute() in D:\Users\Erik\Documents\visual studio 2017\Projects\BuilderBits\BuilderBits\Views\Shared\UserDashboard\_Layout_Dashboard.cshtml:28
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
System.Web.WebPages.<>c__DisplayClass3.<RenderPageCore>b__2(TextWriter writer) +232
System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
System.Web.WebPages.WebPageBase.Write(HelperResult result) +80
System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +63
System.Web.WebPages.WebPageBase.PopContext() +237
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +98
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +235
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765045
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
When you try to include the partial view using #Html.Partial("_PartialHeader_Dashboard") , MVC framework will try to load the partial views from the below locations as per the MVC conventions.
~/Views/DirectoryWithYourCurrentControllerName/
~/Views/Shared/
The framework has no idea your partial view is inside a sub directory unless you tell the framework to do so by extending the view engine and specifying the view file location(ViewLocationFormats). All you need to do is add your custom location.
You have 2 options
Call the partial view with the directory name (which is under shared)
#Html.Partial("UserDashboard/_PartialHeader_Dashboard")
Or
Use the full file path
#Html.Partial("~/Views/Shared/UserDashboard/_PartialHeader_Dashboard.cshtml")
But a better option is to consider Areas. Areas are present for logically keeping things (controllers/ views etc) together.
Related
First of all, this could very well be a rookie mistake on my part, I'm fairly new to .net and c#.
I'm using the CMS system Umbraco on our latest project, and a recent update has meant the system has started using the System.Globalization.CultureInfo class to deal with localization. This has resulted in multiple "Culture Not Found" errors in the CMS back office that renders it unusable. Here's a stack trace from one of them:
Server Error in '/' Application.
Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.
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.Globalization.CultureNotFoundException: Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.
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:
[CultureNotFoundException: Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.]
System.Globalization.CultureInfo.GetCultureInfo(String name) +12488971
Umbraco.Core.Services.LocalizedTextServiceFileSources.<.ctor>b__0() +573
System.Lazy`1.CreateValue() +180
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26
System.Lazy`1.get_Value() +12446617
Umbraco.Core.Services.LocalizedTextServiceFileSources.TryConvert2LetterCultureTo4Letter(String twoLetterCulture) +61
Umbraco.Core.Services.LocalizedTextService.ConvertToSupportedCultureWithRegionCode(CultureInfo currentCulture) +110
Umbraco.Core.Services.LocalizedTextService.GetAllStoredValues(CultureInfo culture) +72
Umbraco.Web.Editors.BackOfficeController.LocalizedText(String culture) +123
lambda_method(Closure , ControllerBase , Object[] ) +77
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765121
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I'm still not completely sure where the .-no is coming from, but after some amount of research into this I tried running the following code with a breakpoint inserted:
var locale = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
This returned null, and doesn't seem to be throwing an exception anywhere. I'm guessing this might be the cause of the errors, judging by the stack trace. Could this be an issue with my local setup? I'm running Windows 10, mainly in a virtualization environment, but it can also run natively via OSX Bootcamp, where the problem still seems to be present. I've also tried using Powershell to output the list of installed cultures, and that works fine.
If it helps, I'm using IISExpress for the web server and the database is running under SQL Server 2016 Express.
Thanks in advance! Let me know if I can supply any extra info to help out with this.
Make use of the fact that Umbraco is open source.
Judging from the stack trace and exception details you have provided, problem is caused by this line:
https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs#L102
Apparently invalid value .-no is passed into GetCultureInfo method. If you look a bit up in the source code, it seems that this value comes from XML file name or XML file content.
I cannot provide complete solution for your problem, but here are some things to try to pinpoint root cause of it:
1) Clean deployment folder
Do full clean & rebuild cycle
2) Check localization XML files to check if they contain valid cultures
If you have edited files manually, make sure there is no typo there.
3) Compare folders of "fresh" install and your non-working solution folder
Check if update hasn't left behind some XML files from previous versions;
I have an MVC program I am currently working and it has been a bit tricky because I have a Turkish Language resource implemented but whenever I fire up the site it insists that there is something wrong with the views. I have gotten the site to work when I set my locale in the DB from
'tr-TR' to 'tr'
The error only seems to have stopped happening, but I would like to know if anyone can elaborate on why .NET seems to be accepting the locale 'tr' instead of 'tr-TR'
[InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/register/Index.cshtml
~/Views/register/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml]
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +356626
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +121
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
GoRun.Core.Web.HttpMethodActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) in c:\HttpMethodActionInvoker.cs:10
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +23
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
After a substantial amount of time I figured that when trying to access the 'index' (the i in the url path is case sensitive and becomes exceptionally sensitive according to the turkey test)
http://localhost:54133/Demo/Register/index
and
http://localhost:54133/Demo/Register/Index
will yield a different results in Turkish locale... We ended up utilizing an application filter that applies '.tolocalinvariant' whenever the Routepath is called.
I am using Rotativa to generate Views as PDF and it runs/works perfectly on my localhost. However when deployed to either a shared host on GoDaddy or my Azure website instance I get the following error.
I attempted to grant permissions on .exe in the Rotativa folder with no luck, also tried running with Full Trust and still getting the error.
ERROR / STACKTRACE
Access is denied
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.ComponentModel.Win32Exception: Access is
denied
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:
[Win32Exception (0x80004005): Access is denied]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo
startInfo) +1789 System.Diagnostics.Process.Start() +6735098
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String
switches, String html) +226
Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) +26
Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +128
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
+173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult
asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult
asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
+31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+9514928 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
CONTROLLER
public ActionResult Print(Guid reportId)
{
var report = new ViewAsPdf("Index", new { id = reportId}) { FileName = "testReport.pdf" };
return report;
}
PERMISSIONS
I tried to set permissions on the entire folder "Rotativa" with full control and now I get this...
This program is blocked by group policy. For more information, contact
your system administrator
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.ComponentModel.Win32Exception: This program
is blocked by group policy. For more information, contact your system
administrator
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:
[Win32Exception (0x80004005): This program is blocked by group policy.
For more information, contact your system administrator]
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo
startInfo) +1789 System.Diagnostics.Process.Start() +6735098
Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String
switches, String html) +226
Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) +26
Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) +128
Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
+173 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult
asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult
asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
+31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+9514928 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
UPDATE JAN 13/2015
I ended up switching to TuesPechkin which has been a far easier solution to work with. GoDaddy does support FullTrust as does Azure, however Azure has a known issue with running processes that call into the GDI which most wkhtmltopdf libraries do. TuesPechkin didn't work on Azure either so I never found a solution for an Azure website, but TuesPechkin worked perfect on GoDaddy hosting with the set in my web.config.
I think both GoDaddy and azure websites don't allow for "Full trust" IIS hosting mode, and that's required in order to run the wkhtmltopdf process.
You should look for a hosting provider that gives full trust access if you want to use Rotativa.
For me I fixed the problem by allowing access to "Everyone" with full permission on the security pane of the file wkhtmltopdf.exe
I hope this helped someone if using a local testing machine or a virtual machine.
Note that you should also give the same allow permission to folder that will save the pdf output.
I know this question have been asking many times but none of then have solved my situation.
I have this simple code
Image f = Image.FromFile(#"\\NetWork\imagenes\folder0\1690D-PC.tif");
But it throws:
System.IO.FileNotFoundException \\NetWork\imagenes\folder0\1690D-PC.tif
I have total access to the related network
I do can find the image in that location. I copy the path, START + r, pasted the path and the image opens.
Is the same for all images in that server.
But the situation not only remains there:
I tested in another pc to checked if is was a IIS problem or
whatever, but when I tested it throws the same(2 pc cannot access to
that file, having they full access... weird...)
When im in development, I can find the image everything work normaly, but when i deploy and
upload to my local iis and the other pc, throw the related exception(FileNotFoundException).
My parner has the same code(almost the same proyect, just with some
diferrent functionality and public) and he can find the image and
display it.
I ran into this situation last friday and i havent came up with a solution yet.
Im willing to hear all your suggestions.
Update 2.
More info:
There are 2 more application that request images from that server and those application can find it normally. Those application are in my local IIS.
Updte
Tracktrace
[FileNotFoundException: \\DAVID-PC\imagenes\folder0\1690D-PC.tif]
System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement) +472351
System.Drawing.Image.FromFile(String filename) +6
Muckup.Controllers.HomeController.Index() in C:\Users\pkm\Documents\Visual Studio 2010\Projects\Muckup\Muckup\Controllers\HomeController.cs:20
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +211
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514812
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Have you tried using double back slashes instead of # to find the file? Might be worth trying.
Image f = Image.FromFile(" *FullPath* \\NetWork\\imagenes\\folder0\\1690D-PC.tif");
I've been working on building an API for my company's website. I've got actions for all of my GETs working fine and returning JSON like I want.
I'm having problems when it comes to using POST to create new records though. I'm sending JSON to my controller. This works fine if my controller is accepting a string or object parameter, but doesn't work when it is expecting a Model.
Inside my api controller, I have this method:
[HttpPost]
public void POSTEstimate(Estimate estimate)
{
//never makes it to the first line when expecting a Model (Estimate)
}
From what I've been reading it looks like Web API should be able to deserialize the JSON that is posted automatically (and put it into my Model), but instead I always get a 500 Internal Server Error. The method works fine when I tell it to accept a string.
Is there something obvious I'm doing wrong here?
Edit: Here's the stack trace from the test page I'm using to call the API Method:
[WebException: The remote server returned an error: (500) Internal Server Error.]
System.Net.HttpWebRequest.GetResponse() +6120419
PDR.Controllers.AdminController.test() in c:\PDR\PDR\PDR\Controllers\AdminController.cs:714
lambda_method(Closure , ControllerBase , Object[] ) +96
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +205
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +50
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +237
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +126
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +45
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +61
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +49
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +49
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9042109
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Web API, like other REST frameworks, is encouraging and supporting using a POCO serializable to JSON DTO. The serialization seems to be failing.
Without the client code, which should be creating a properly formatted JSON body to POST, properly setting the content type being posted as application/json, it is hard to tell which part of the client code isn't correct.
The error being reported as an internal server error isn't helpful. The fact that your code isn't being reached, without even looking at the StackTrace, clearly indicates that the issue is occurring in framework code. The framework is expecting a properly formatted DTO, so compare the DTO being POST'd vs the DTO's definition OR construct and serialize an instance of the DTO and compare the actual strings.
I fell on something similar today, and my issue was that there were multiple possible actions in my controller that could be used by Web Api and it wasn't able to know which one to use. So in my case I used the longest form client-side and server-side for the action, instead of relying on default api route :
Router:
config.Routes.MapHttpRoute(
name: "ApiWithAction",
routeTemplate: "metadataApi/{controller}/{action}/{id}",
defaults: new {id = RouteParameter.Optional});
Ajax call:
[...]
var options = {
url: basePath + 'metadataapi/employee/FetchPage',
type: 'POST',
data: filter,
dataType: 'json'
};
return $.ajax(options);