using System.Web.Mvc;
using Umbraco.Web.Mvc;
using themenseiten.businesslogic.API;
namespace themenseiten.businesslogic.Controller
{
public class myLoginController : SurfaceController
{
public myLoginController() { }
[HttpPost]
public ActionResult Authenticate(themenseiten.businesslogic.Models.myLoginModel login)
{
var memberApi = new chbeckMembership();
return Content(memberApi.isAuthenticated(login.Login, login.Password).ToString());
}
}
}
And this is the model:
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
namespace themenseiten.businesslogic.Models
{
[Serializable]
public class myLoginModel
{
[Required]
[DisplayName("Benutzername")]
public string Login { get; set; }
[DisplayName("Passwort")]
[Required]
public string Password { get; set; }
}
}
If I click on the "Login"-Button, the "Authenticate"-Method is called, but the myLoginModel contains the value "null".
Very very strange... I have two projects in visual studio. One Project "themenseiten.businesslogic" with the model and controller and one project "themenseiten.web" with the umbraco site and the views.
Now, I have copy the same model and controller in the themenseiten.web project and all works great. But in the first project the model is null.
It seems to be a configuration problem with references and other things in visual studio.
There are no secret variable names and the model binding happens with normal mvc, I suspect it's something to do with you passing in a value on your button called 'login' and you have a property in your model called login, probably confusing the model binder. Much easier to debug such things if you see what is actually posted in chrome dev tools or fiddler
Model in Surface is Controller is null
Hi all,
I have a very strange issue with a simple surface controller in 7.2.8.
This is the partial view:
This is the Surface Controller:
And this is the model:
If I click on the "Login"-Button, the "Authenticate"-Method is called, but the myLoginModel contains the value "null".
Have anyone an idea and can help me?
Cheers,
Sören
Hi, I would try
taking the [Serializable] of the model Posting using HTML.begin form
That way at least you can zero in on the problem.
Nothing I can see looks really wrong they are only string properties.
Hi Charles,
thanks, but this don't solved the problem. The model is each time null.
Ok so try removing the second parameter from textboxfor? I wonder if the parameters are wrong on the input
Same result :( model is null
Very very strange... I have two projects in visual studio. One Project "themenseiten.businesslogic" with the model and controller and one project "themenseiten.web" with the umbraco site and the views.
Now, I have copy the same model and controller in the themenseiten.web project and all works great. But in the first project the model is null.
It seems to be a configuration problem with references and other things in visual studio.
Has someone an idea?
I have solved it!!!
But the cause for this issue is incomprehensible and impossible for me!
The issue occurs if I call my model in action method of surface controler "login":
If I rename the variable, i.e. "tModel", then it works great:
It seems, that there exist an global model with the name "login" and this cause the conflicts.
Is there somewhere an overview of such global variables?
Cheers,
Sören
There are no secret variable names and the model binding happens with normal mvc, I suspect it's something to do with you passing in a value on your button called 'login' and you have a property in your model called login, probably confusing the model binder. Much easier to debug such things if you see what is actually posted in chrome dev tools or fiddler
is working on a reply...