RAZOR中的CSHTML如何调用方法呢?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;namespace MyGame
{
public class AppGlobalInfo
{
public static string ThemeName()
{
return "Default";
}
}
}
@{
Layout = "~/Views/Themes/MyGame/My/_Administrator.cshtml";
ViewBag.Title = "???";
}
@for (int i = 0; i < 100; i++)
{
@AppGlobalInfo.AppGlobalInfo.ThemeName();
<p style="font-size:10px;">@i</p>
}
Server Error in '/' Application.Compilation ErrorDescription: 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: CS0433: The type MyGame.AppGlobalInfo' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\74643291\eb640423\assembly\dl3\ff8dc3e8\002f0e16_0f51cd01\MyGame.dll' and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\74643291\eb640423\App_Code.a9cl9ms2.dll'
Source Error:
Line 6: @for (int i = 0; i < 100; i++)Line 7: {Line 8: @MyGame.AppGlobalInfo.ThemeName();Line 9: <p style="font-size:10px;">@i</p> Line 10: }
------解决方案--------------------@AppGlobalInfo.AppGlobalInfo.ThemeName();
是否应是@AppGlobalInfo.ThemeName();
------解决方案--------------------@Html.Raw(AppGlobalInfo.AppGlobalInfo.ThemeName());