Search code examples
asp.net-mvcasp.net-mvc-2redirecttoaction

RedirectToAction hangs without redirecting


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?


Solution

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