我在我的MVC3应用程序中收到此错误.请帮忙...
错误:
An object reference is required for the non-static field, method, or property 'System.Web.Mvc.Controller.HttpContext.get'
在线:
string desigId = HttpContext.Current.Session["Desig_Id"].ToString();
类中的代码及其方法:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Helpers;
using System.Net.Mail;
using System.Net;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
namespace ApricaCRMEvent.Controllers
{
public class NotificationController : Controller
{
//to send email notification
[Authorize]
public static string SendEmailNotification(int crmId, string username, string action)
{
string desigId = HttpContext.Current.Session["Desig_Id"].ToString();
}
}
}
Run Code Online (Sandbox Code Playgroud)
Den*_*nis 16
您的基类Controller已经实现了一个属性HttpContext.
你可以完全引用它:System.Web.HttpContext.Current...或者使用你的控制器的属性,就像HttpContext.Session.对于第二个选项,您的方法必须是non-static.
| 归档时间: |
|
| 查看次数: |
25434 次 |
| 最近记录: |