RedirectToAction 挂起而不重定向
我有以下代码用于在我的应用程序中注册用户
[HttpPost]
public virtual ActionResult Register( RegisterModel model ) {
if ( !ModelState.IsValid ) {
//Invalid - redisplay form with errors
return View( model );
}
try {
MembershipUser mu = _manager.RegisterUser( model );
//Send confirmation email here
}
catch ( RegistrationException rex ) {
ModelState.AddModelError( "", rex.Message );
}
return RedirectToAction( "Index", "Home" );
}
如果用户在系统上正确注册,我会将他重定向到应用程序的主页,并且
return RedirectToAction( "Index", "Home" );
此代码在我的开发盒和临时服务器中工作。但是,当我将其发布到可通过互联网访问的生产服务器上时,它会在发送电子邮件后的最后一次调用中挂起,而根本不会重定向用户。
有什么想法吗?
I have the following code for registering users in my app
[HttpPost]
public virtual ActionResult Register( RegisterModel model ) {
if ( !ModelState.IsValid ) {
//Invalid - redisplay form with errors
return View( model );
}
try {
MembershipUser mu = _manager.RegisterUser( model );
//Send confirmation email here
}
catch ( RegistrationException rex ) {
ModelState.AddModelError( "", rex.Message );
}
return RedirectToAction( "Index", "Home" );
}
If the user get correctly registered on the system I am redirecting him to the Home page of the app with
return RedirectToAction( "Index", "Home" );
I have this code working in my dev box and in my staging server. But when I publish it on the production server accessible through the internet it hangs on the last call, after sending the email, without redirecting the user at all.
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Lorenzo,
我认为您的远程邮件设置可能有错误(配置和/或禁用),并且此错误正在您的 try/catch 块中被“吞没”。尝试禁用该块,您应该能够看到服务器上发生的实际错误。我的直觉是,这就是问题所在!我已经多次走这条路了,所以你并不孤单。
切换到“现场”环境的乐趣......
干杯......
Lorenzo,
I think that you may have an error (configuration and/or disabled) with the remote mail setup and this error is being 'swallowed' in your try/catch block. Try disabling that block and you should be able to see the actual error that occurred on the server. My gut feel is that this is where the issue lies!! I've gone down this path MANY a time, so you're not alone.
The joys of switching to a 'live' environment...
cheers...