我需要使用基于视图的授权,当我执行以下操作时,我在应用程序中得到了服务器错误
@if (User.Identity.IsAuthenticated)
{
if (User.IsInRole("Admin"))
{
<h4>Create a new document</h4>
@using(Html.BeginForm("Create", "Document", null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<span>SOME HTML COD</span>
}
}
else
{ <span>Vous devez être administrateur pour accéder à cette section</span>}
}
else
{<span>Vous devez être connecté pour accéder à cette section</span>}解决方案或问题可能是什么?
发布于 2019-01-20 09:58:33
从使用中删除@(Html.BeginForm.只有在div标记中有任何条件时,才需要“,”。
@if (User.Identity.IsAuthenticated)
{
if (User.IsInRole("Admin"))
{
<h4>Create a new document</h4>
using (Html.BeginForm("Create", "Document", null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<span>SOME HTML COD</span>
}
}
else
{ <span>Vous devez être administrateur pour accéder à cette section</span>}
}
else
{<span>Vous devez être connecté pour accéder à cette section</span>}https://stackoverflow.com/questions/54275128
复制相似问题