【发布时间】:2016-08-17 09:26:46
【问题描述】:
我有一个问题,在我上面的代码中,前两个页面以完美的方式工作,但最后一个页面只显示一个页面,其中只有一行代码细节。我需要帮助!!
@if (((RegisteredUser)Session["User"]).IsExpert)
{
<li>@Html.ActionLink("Área técnica", "Index", "Dashboard", new { area = "Expert" }, null)</li>
}
@if (((RegisteredUser)Session["User"]).IsServiceDeskAdmin)
{
<li>@Html.ActionLink("Área de administração", "Index", "Dashboard", new { area = "Administration" }, null)</li>
}
@if (((RegisteredUser)Session["User"]).IsExpert)
{
<li>@Html.ActionLink("Perfil", "Index", "PerfilController", new { area = "Perfil" }, null)</li>
}
上面的代码是 .cs 文件。谢谢
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Mvc;
namespace Fcebi.ServiceDesk.WebPlatform.Controllers
{
public class PerfilController : Controller
{
// GET: Perfil
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
Fcebi.ServiceDesk.WebPlatform.Areas.Expert.ExpertAuth.DoAuth(Session, Request, filterContext, Url);
}
public ActionResult Index(String Id)
{
// Id = api da tabela User
Id = "Id7dkSro7Qh";
if (String.IsNullOrEmpty(Id) || String.IsNullOrWhiteSpace(Id))
{
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "O ID do utilizador tem de ser definido");
}
else
{
try
{
RegisteredUser U = RegisteredUser.FindByAPI(Id);
var JsonToReturn = new
{
Name = U.Name,
Departamento = U.Department,
Email = U.Email,
signature=U.Signature
};
return Json(JsonToReturn, JsonRequestBehavior.AllowGet);
}
catch (ServiceDeskException Ex)
{
return new HttpStatusCodeResult((int)Ex.ErrorId, Ex.Message);
}
catch (Exception Ex)
{
new ServiceDeskException(ServiceDeskException.ErrorList.OTHER, Ex);
return new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, Ex.Message);
}
}
}
}
}
【问题讨论】:
-
您的措辞不清楚。您的意思是 链接 没有正确显示,或者 通过单击链接呈现的页面 没有正确显示?我不知道你所说的“只有一行代码细节”是什么意思
-
链接不工作100%,页面没有重定向,当我强制链接到页面时,只出现一行用户信息,我想显示配置良好的页面,我复制并粘贴了有效页面的代码,因此更改了变量和我想要显示的内容
-
actionlink 渲染的 html 是什么样的?这是否对应于您的应用程序中的真实控制器和操作?
-
这就像一个空白页面,其中一行信息,而不是,真正的控制器是一个带有默认布局和我需要显示的信息的html页面。但是链接上的两个页面(“专家”和“管理”)是有效的
-
不,我问的是 actionlink 呈现的 html 是什么样的。我在问它是否绝对指向正确的地方?
标签: c# html actionlink html.actionlink