我有一个在我的开发环境中运行良好的 MVC 3 应用程序(您之前一定听说过..)我将它部署到免费托管服务http://somee.com进行测试,.NET 框架设置为 4 . 我有一个自定义会员提供程序。我可以注册一个用户,因为我可以在数据库中看到它,但用户永远不会获得身份验证。在注册后或登录时,我总是被重定向到登录页面。我已经完成了 bin 部署,并且在我的 bin 文件夹中有这个 dll:
•System.Web.Mvc
•Microsoft.Web.Infrastructure
•System.Web.Razor
•System.Web.WebPages •System.Web.WebPages.Razor
•System.Web.Helpers
在配置中:...
<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>
控制器:
[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(); }
现在没有想法了...