我很奇怪,爲什麼以下內容:剃鬚刀,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