MVC中很奇怪的问题

Y2zz Y2zz 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
新建了一个MVC 3的项目, 在HomeController中继承BaseController
 1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Web;
5 using System.Web.Mvc;
6 using System.Web.UI;
7
8 using Cloud.Config;
9
10 namespace UserCenter.Controllers
11 {
12 public class HomeController : BaseController
13 {
14 public HomeController()
15 {
16 }
17
18 //
19 // GET: /Home/
20
21 public ActionResult Index()
22 {
23 return View();
24 }
25
26 }
27 }


BaseController代码如下
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
using Cloud.Config;

namespace UserCenter.Controllers
{
/// <summary>
/// 基础
/// </summary>
public class BaseController : Controller
{
public BaseController()
{
if(Cookie("login") == null)
{
          // 这地方报错, 未将对象引用设置到对象的实例。
Response.Redirect(Url.Action("Login", "Account"));

          // 这地方不报错
          System.Web.HttpContext.Current.Response.Redirect(Url.Action("Login", "Account"));
}
}
  }
}

命名里的为啥就要补全? 简写语法不报错, 但是执行的时候就报错了
我已经引用了, 如果没引用报错我认了, 但这问题真的很崩溃
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
Y2zz
C# 111,129 成员 642,538 内容