CS0103 C#当前上下文中不存在名称“ Json” [英] CS0103 C# The name 'Json' does not exist in the current context

查看:1120
本文介绍了CS0103 C#当前上下文中不存在名称“ Json”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧

我写了JsonResult函数。但是我遇到以下错误:

I have written JsonResult funtion. But i get the following error:


CS0103 C#名称 Json在当前上下文中不存在

CS0103 C# The name 'Json' does not exist in the current context

我找不到解决方案...请帮助?

I cant find solution to it... plzz help?

public JsonResult DoUserExist(string Emailaddress)
{
    bool ch = false;
    string connectionString = ConfigurationManager.ConnectionStrings["FreelanceDBCS"].ConnectionString;

    using (SqlConnection con = new SqlConnection(connectionString))
    {
        SqlCommand cmd = new SqlCommand("GetCities", con);
        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        con.Open();
        SqlDataReader rdr = cmd.ExecuteReader();


        if (rdr != null)
        {
            ch = true;
        }
    }
    return Json(ch,JsonRequestBehavior.AllowGet);

}


推荐答案

!!

我忘了从控制器类派生我的类

I have forgotten to derive my class from Controller class

public class User: Controller
{

}

这篇关于CS0103 C#当前上下文中不存在名称“ Json”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆