我正在创建一个 MVC 4 应用程序,我遇到了如下错误。
我尝试了很多东西,但我找不到问题所在。这是我的 Controller 源代码
public ActionResult Index(string EventId)
{
HttpCookie cookie = this.ControllerContext.HttpContext.Request.Cookies["User"];
if (cookie != null)
{
string Type = (cookie["Type"] == null || cookie["Type"] == "") ? null : cookie["Type"].ToString();
string Username = (cookie["Username"] == null || cookie["Username"] == "") ? null : cookie["Username"].ToString();
ViewBag.Message = Type;
ViewBag.Username = Username;
try
{
string ReplaceEventID = EventId.Replace('-', '/');
ViewBag.Message = ReplaceEventID;
IEnumerable<Job> JobListRelatedToEvent = DBContext.Jobs.Where(x => x.EventId == ReplaceEventID);
return View(JobListRelatedToEvent);
}
catch
{
return View();
}
}
else
{
return RedirectToAction("Index", "Home");
}
}
更新: 当它在我的本地机器上运行时它工作正常,但在我发布到服务器后我得到了这个错误。
谁能告诉我哪里出了问题?
最佳答案
我遇到了同样的问题,如果出现自定义错误,我们就会遇到这个问题。
您需要在 web.config 中进行更改并添加以下代码。 因此,您将获得应用程序或代码级别的实际错误。
<system.web>
<customErrors mode="Off" />
现在安装 IIS 的通用页面,它将显示错误。
关于c# - 处理您的请求时发生错误。 MVC 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24300869/