RedirectToAction 挂起而不重定向

发布于 2024-10-05 14:33:17 字数 722 浏览 0 评论 0原文

我有以下代码用于在我的应用程序中注册用户

[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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠佳期 2024-10-12 14:33:17

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文