2

I tried this tutorial for my xamarin app, with this code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace XamarinLogin.Controllers
{
    public class ControllerNameController : ApiController
    {
        // GET: api/ControllerName
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET: api/ControllerName/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/ControllerName
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/ControllerName/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/ControllerName/5
        public void Delete(int id)
        {
        }
         xamarinloginEntities db = new xamarinloginEntities();  

        [HttpPost]  
        [ActionName("XAMARIN_REG")]  
        // POST: api/Login  
        public HttpResponseMessage Xamarin_reg(string username, string password)  
        {  
            Login login = new Login();  
            login.Username = username;  
            login.Password = password;  
            db.Logins.Add(login);  
            db.SaveChanges();  
            return Request.CreateResponse(HttpStatusCode.Accepted, "Successfully Created");  
        }  
        [HttpGet]  
        [ActionName("XAMARIN_Login")]  
        // GET: api/Login/5  
        public HttpResponseMessage Xamarin_login(string username, string password)  
        {  
            var user = db.Logins.Where(x => x.Username == username && x.Password == password).FirstOrDefault();  
            if (user == null)  
            {  
                return Request.CreateResponse(HttpStatusCode.Unauthorized, "Please Enter valid UserName and Password");  
            }  
            else  
            {  
                return Request.CreateResponse(HttpStatusCode.Accepted, "Success");  
            }  
        }  

    }
}

I'm already following exactly like the tutorial but I still got an error message, and this is the error message,

The type or namespace name xamarinloginentities could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name Login could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name xamarinloginentities could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name Login could not be found (are you missing a using directive or an assembly reference?)

as you can see Login and xamarinloginentities is my ADO.NET Entity Data Model the question is how can I get this error message.

1 Answer 1

1

The type or namespace name xamarinloginentities could not be found (are you missing a using directive or an assembly reference?)

Per my understanding, the class name (e.g xamarinloginEntities) need to be case sensitive. Additionally, if you follow the tutorial you provided, the ASP.NET Entity Data Model would be defined under your Project Name -> Models, for your ControllerNameController.cs, you need to add the namespace reference as follows:

using XamarinLogin.Models;
Sign up to request clarification or add additional context in comments.

1 Comment

Glad to hear that you have solved this issue. Any concerns, feel free to let us know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.