处理您的请求时发生错误.MVC 4

 LIU在笑_139 发布于 2023-01-08 15:41

我正在创建一个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 JobListRelatedToEvent = DBContext.Jobs.Where(x => x.EventId == ReplaceEventID);
                return View(JobListRelatedToEvent);
            }
            catch
            {
                return View();
            }
        }
        else
        {
            return RedirectToAction("Index", "Home");
        }
    }

更新: 当它在我的本地机器上运行时它工作正常,但在我发布到服务器后,我得到了这个错误.

谁能说出错是什么意思?

1 个回答
  • 我遇到了同样的问题,如果自定义错误打开,我们会遇到这个问题.

    您需要在web.config中进行更改并添加以下代码.因此,您将获得应用程序的实际错误或代码级别.

    <system.web>
          <customErrors mode="Off" />
    2023-01-08 15:44 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有