Razor 将cshtml转换为vbhtml

Razor 将cshtml转换为vbhtml,razor,Razor,我正在将使用C#创建的局部视图转换为VB,需要一些帮助来转换下面的源代码片段 @使用Microsoft.AspNet.Identity @如果(请求已验证) { 使用(Html.BeginForm(“注销”、“帐户”、FormMethod.Post、新的{id=“logoutForm”、@class=“navbar right”})) { @Html.AntiForgeryToken() @ActionLink(“Hello”+User.Identity.GetUserName()+”!,

我正在将使用C#创建的局部视图转换为VB,需要一些帮助来转换下面的源代码片段

@使用Microsoft.AspNet.Identity
@如果(请求已验证)
{
使用(Html.BeginForm(“注销”、“帐户”、FormMethod.Post、新的{id=“logoutForm”、@class=“navbar right”}))
{
@Html.AntiForgeryToken()
  • @ActionLink(“Hello”+User.Identity.GetUserName()+”!,“Manage”,“Account”,routeValue:null,htmlAttributes:new{title=“Manage”})
} } 其他的 {
  • @ActionLink(“Register”、“Register”、“Account”、routeValue:null、htmlAttributes:new{id=“registerLink”})
  • @ActionLink(“登录”、“登录”、“帐户”、routeValue:null、htmlAttributes:new{id=“loginLink”})
}
引用:

在服务器代码块中,通常需要将文本和标记输出到页面。如果服务器代码块包含的文本不是代码,而是应按原样呈现的文本,则ASP.NET需要能够区分该文本和代码。例如:

@如果是IsPost那么
'此行包含匹配的标记之间的所有内容。
@ 您好,时间是@DateTime.Now,此页面是回发

其他的 '匹配标记之间的所有内容,后跟服务器代码。 @ 你好,陌生人!今天是:

@DateTime.Now 如果结束
以下是您转换的代码:

@Imports Microsoft.AspNet.Identity
@If Request.IsAuthenticated Then
    Using Html.BeginForm("LogOff", "Account", FormMethod.Post, New With {.id = "logoutForm", .class = "navbar-right"})
        @Html.AntiForgeryToken()

        @<ul class="nav navbar-top-links navbar-right">
            <li>@Html.ActionLink("Hello " & User.Identity.GetUserName() & "!", "Manage", "Account", routeValues:=Nothing, htmlAttributes:=New With {Key .title = "Manage"})</li>
            <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
        </ul>
    End Using
Else
    @<ul class="nav navbar-top-links navbar-right">
        <li>@Html.ActionLink("Register", "Register", "Account", routeValues:=Nothing, htmlAttributes:=New With {Key .id = "registerLink"})</li>
        <li>@Html.ActionLink("Log in", "Login", "Account", routeValues:=Nothing, htmlAttributes:=New With {Key .id = "loginLink"})</li>
    </ul>
End If
@导入Microsoft.AspNet.Identity
@如果Request.IsAuthenticated,则
使用Html.BeginForm(“注销”、“帐户”、FormMethod.Post,新增为{.id=“logoutForm”,.class=“navbar right”})
@Html.AntiForgeryToken()
@
  • @ActionLink(“Hello”&User.Identity.GetUserName()&“!”,“Manage”,“Account”,routeValue:=Nothing,htmlAttributes:=带有{Key.title=“Manage”}的新属性)
终端使用 其他的 @
  • @ActionLink(“Register”、“Register”、“Account”、routeValue:=Nothing,htmlAttributes:=带有{Key.id=“registerLink”}的New)
  • @ActionLink(“登录”、“登录”、“帐户”、RouteValue:=无,htmlAttributes:=使用{Key.id=“loginLink”}新建)
如果结束
@Imports Microsoft.AspNet.Identity
@If Request.IsAuthenticated Then
    Using Html.BeginForm("LogOff", "Account", FormMethod.Post, New With {.id = "logoutForm", .class = "navbar-right"})
        @Html.AntiForgeryToken()

        @<ul class="nav navbar-top-links navbar-right">
            <li>@Html.ActionLink("Hello " & User.Identity.GetUserName() & "!", "Manage", "Account", routeValues:=Nothing, htmlAttributes:=New With {Key .title = "Manage"})</li>
            <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
        </ul>
    End Using
Else
    @<ul class="nav navbar-top-links navbar-right">
        <li>@Html.ActionLink("Register", "Register", "Account", routeValues:=Nothing, htmlAttributes:=New With {Key .id = "registerLink"})</li>
        <li>@Html.ActionLink("Log in", "Login", "Account", routeValues:=Nothing, htmlAttributes:=New With {Key .id = "loginLink"})</li>
    </ul>
End If