Well,
I have written JsonResult funtion. But i get the following error:
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);
}
CS0103 is caused when you are using a name for a variable or method that does not exist within the context that you are using it. In order to fix the CS0103 error you will need to correct the name of the variable or method from where it is declared or referenced.
An attempt was made to use a name that does not exist in the class, namespace, or scope. Check the spelling of the name and check your using directives and assembly references to make sure that the name that you are trying to use is available.
To fix this error, simply update the example . csproj file to use a previous System. CommandLine version. Note that this package is only used to parse the options for the example.
I got it !
I have forgotten to derive my class from Controller class
public class User: Controller
{
}
Page must be derived from Controller class to Json () and JsonResult() part by using Microsoft.AspNetCore.Mvc;
If you are using Razor page model then you can face this issue. I got it after too much time spending.
You can also change your page derived from Controller instead of pagemodel like this public class User: Controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With