0

I have an MVC 3 Application that works fine in my dev environment (you must have heard that before..) I am deploying it to a free hosting service http://somee.com for testing, the .NET framework is set to 4. I have a custom membership provider. I am able to register a user, as I can see it in the database, but the user never gets authenticated. I always get redirected to the LogOn page, either after the registration or when loging on. I have done a bin deployment and have this dlls in my bin folder:

•System.Web.Mvc
•Microsoft.Web.Infrastructure
•System.Web.Razor
•System.Web.WebPages •System.Web.WebPages.Razor
•System.Web.Helpers

In the config: ...

   <add key="loginUrl" value="~/Account/Logon" />
  </appSettings>
....
    <membership defaultProvider="ServiceMembershipProvider">
      <providers>
        <clear/>
        <add name="ServiceMembershipProvider"
             type="Infrastruture.ServiceMembershipProvider, Infrastruture" />
      </providers>
    </membership>
  <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880" />
    </authentication>

The controllers:

  [HttpPost]
        public ActionResult Register(FormCollection registration)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var registrationViewModel = MapFormToRegistrationViewModel(registration);
                    companyManager.RegisterCompany(registrationViewModel);
                    FormsAuthentication.SetAuthCookie(registrationViewModel.SystemUserViewModel.Email, false);
                    return RedirectToAction("Welcome", "Home");
                }
                else
                {
                    ModelState.AddModelError("", "LogId already taken");
                }
            }
            catch(Exception ex)
            {
                               return View("Register", new RegistrationViewModel(dataReferenceService));
            }

            return View("Register", new RegistrationViewModel(dataReferenceService));
        }
    /* /Home/Welcome */
    [Authorize]
    public ActionResult Welcome()
    { return View(); }

Running out of ideas now ...

3
  • 1
    are you missing the dll to your custom Infrastruture.ServiceMembershipProvider? Commented Nov 29, 2011 at 14:54
  • Nope I thought the custom provider could be the cause, but I check for the dll is there and I tested it entering username with wrong password, it gives me the right behaviour. When I give the right username - pwd I just get redirected like if I hadn't been authenticated, when I use a wrong pwd I can see the error message. Commented Nov 29, 2011 at 23:35
  • I should have clafiried, apart from my deployment dlls i have added the System.Web.MVC ... etc Commented Nov 29, 2011 at 23:37

1 Answer 1

2

I know this is an old question but I had a similar problem and found this while searching for the answer.

The solution is to add the following setting to your web config file.

<appSettings>
<add key="enableSimpleMembership" value="false"/>
</appSettings>

The reason this is required is some pre application startup code appears to have some issues with default settings.

A better explaination and the place I found this solution is here

Sign up to request clarification or add additional context in comments.

Comments

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.