【发布时间】:2015-11-13 11:13:53
【问题描述】:
我在我开发的网站上遇到错误,它在本地工作,但我刚刚将它发布到服务器 (vidahost) - 我要做的只是呈现页面创建的时间/日期在。总是这样做,以前从来没有任何问题。我正在使用 Umbraco 7.3
The call is ambiguous between the following methods or properties:
'Umbraco.Web.UmbracoHelper.TypedMedia(params int[])' and 'Umbraco.Web.UmbracoHelper.TypedMedia(params string[])'
堆栈错误;
Server Error in '/' Application.
The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.TypedMedia(params int[])' and 'Umbraco.Web.UmbracoHelper.TypedMedia(params string[])'
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: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.TypedMedia(params int[])' and 'Umbraco.Web.UmbracoHelper.TypedMedia(params string[])'
Source Error:
Line 25: <span class="date">
Line 26: <i class="fa fa-calendar"></i>
Line 27: @CurrentPage.CreateDate.ToString("dd-MM-yyyy")
Line 28: </span>
Line 29: <span class="author">
Source File: \\sambal\sites\liquidthinker.com\public_html\Views\Article.cshtml Line: 27
Stack Trace:
[RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.TypedMedia(params int[])' and 'Umbraco.Web.UmbracoHelper.TypedMedia(params string[])']
CallSite.Target(Closure , CallSite , UmbracoHelper , Object ) +248
ASP._Page_Views_Article_cshtml.Execute() in \\sambal\sites\liquidthinker.com\public_html\Views\Article.cshtml:27
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +110
Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +140
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248
这里是 MVC 视图;
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Root.cshtml";
}
<!-- Article Template -->
<section class="article">
<div class="medium-8 large-8 columns noPaddingLeft border-right left-side-content">
@if (!String.IsNullOrEmpty(CurrentPage.customTitle))
{
<h1 class="pageTitle">
@CurrentPage.customTitle
</h1>
}
else
{
<h1 class="pageTitle">
@CurrentPage.Name
</h1>
}
<div class="blogPostInfo large-12 columns noPadding">
<span class="date">
<i class="fa fa-calendar"></i>
@CurrentPage.CreateDate.ToString("dd-MM-yyyy")
</span>
<span class="author">
<i class="fa fa-pencil"></i>
Damian Hughes
</span>
<span class="comments">
<i class="fa fa-comment"></i>
<a href="@CurrentPage.Url#disqus_thread">0 comments</a>
</span>
</div>
<div class="clearfix"></div>
<div class="fullWidthImage large-12">
<img class="img-thumbnail full" src="@Umbraco.TypedMedia(CurrentPage.blogFullImage).Url" alt="@Umbraco.TypedMedia(CurrentPage.blogFullImage).Name" />
</div>
<div class="blogContent">
@CurrentPage.blogContent
</div>
<div class="socialShare large-12">
<!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="addthis_sharing_toolbox"></div>
</div>
<div class="disqusContainer large-12 columns noPadding">
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//liquidthinker.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</div>
<div class="clearfix"></div>
</div>
<div class="medium-4 large-4 columns" id="booksSideMenu">
@Umbraco.RenderMacro("BooksRightSideMenu")
</div>
</section>
不太明白为什么会出错,我错过了什么?
【问题讨论】:
-
看起来无法区分您发送给 Date 函数的字符串和 Int 函数,尝试强制转换它(字符串),虽然与 MVC 没有太大关系,但哈哈
-
Not Date 抱歉 typemedia(string) 和 typemedia(int) 需要在某处进行转换
标签: c# asp.net-mvc model-view-controller methods properties