我很奇怪,为什么以下内容:剃须刀,ASP.Net,用户认证
@if(Request.LogonUserIdentity.IsAnonymous){
<ul id="menu">
<li>@Html.ActionLink("Location", "Index", "Location")</li>
<li>@Html.ActionLink("Map", "Map", "Home")</li>
<li>@Html.ActionLink("Help", "Help", "Home")</li>
</ul>
@}else if(Request.LogonUserIdentity.IsAuthenticated){
<ul id="menu">
<li>@Html.ActionLink("Location", "Index", "Location")</li>
<li>@Html.ActionLink("Service", "Index", "Service")</li>
<li>@Html.ActionLink("Service Assignment", "Index", "ServiceAssignment")</li>
<li>@Html.ActionLink("Content Management", "Index", "Content")</li>
</ul>
@}
抛出以下错误:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1501: No overload for method 'Write' takes 0 arguments
这个错误是我else if
块抛出。我是ASP.net和剃须刀的新手,但是从我的理解来看,我所做的是正确的?因为它们都是布尔返回。
或者只是使用@if。由于每个块内的HTML标签都是有效的,Razor可以发现else和else括号是代码。 – 2013-04-11 15:52:10
@JasonBerkan - 好点。我认为这两种方法在这一点上只是风格选择。 – Tommy 2013-04-11 15:53:05