locked
RedirectToAction hangs indefinitely RRS feed

  • Question

  • User327468921 posted

    Dear all,

    Today I've been trying to solve the strangest behavior ever.. This simplified piece of code gets executed after I submit a form with only a login and password. The strange thing is that when the password contains an @ the RedirectToAction hangs indefinitely and when I use a password without an @ It works fine.

    [HttpPost]
    public ActionResult Index(FormCollection collection)
    {
        var login = collection["txtLogin"];
        var password = collection["txtPassword"];
        return RedirectToAction("Index", "Password");
    }

    Is there anyone who has any idea??

    Friday, August 7, 2020 4:15 PM

Answers

  • User327468921 posted

    Looks like a problem with the Chrome password save mechanisme. I used a real login and password of an existing survey that was saved before and I think that somehow that is the culprit. When I used a new login and password (also with an @ in it) the redirect functioned as expected. When I deleted all saved passwords the problem also disappeared. Also when debugging in other browsers the problem did not appear.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 10, 2020 1:20 PM

All replies

  • User1120430333 posted

    Some sites restrict special character usage in a password. I am sure you have encountered it. Maybe should filter the password usage to not accept an @ sign.  

    Friday, August 7, 2020 9:22 PM
  • User475983607 posted

    I cannot reproduce this behavior.  Share all the relevant code if you still need help.

        public class BasicFormsController : Controller
        {
            // GET: BasicForms
            [HttpGet]
            public ActionResult Index()
            {
                return View();
            }
    
            [HttpPost]
            public ActionResult Index(FormCollection collection)
            {
                var login = collection["txtLogin"];
                var password = collection["txtPassword"];
                return RedirectToAction("Index", "BasicForms");
            }
    
    
        }
    @{
        ViewBag.Title = "Index";
    }
    
    <h2>Index</h2>
    
    <form method="post">
        <div>
            <input id="txtLogin" type="text" name="txtLogin" />
        </div>
        <div>
            <input id="txtPassword" type="text" name="txtPassword" />
        </div>
        <div>
            <input id="Submit1" type="submit" value="submit" />
        </div>
    </form>

    Friday, August 7, 2020 9:31 PM
  • User1686398519 posted

    Hi edwinhebbink,

    I cannot reproduce your problem based on the code you currently provide. You can provide more code if it is convenient for you.Or you can give a screenshot of the error so that we can better help you.

    Best Regards,

    YihuiSun

    Monday, August 10, 2020 7:20 AM
  • User327468921 posted

    I have create a small MVC site from a default template and It behaves the same way. So just create a new web application in Visual Studio and in the HomeController place this extra method

    [HttpPost]
    public ActionResult Index(FormCollection collection)
    {
    var login = collection["txtLogin"];
    var password = collection["txtPassword"];

    return RedirectToAction("Contact", "Home");
    return View();
    }

    Then in the Home/Index view place this login form

    <div class="col-md-4">
    @using (Html.BeginForm())
    {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <div class="form-group">
    <label for="inputLogin">Login</label>
    <input type="text" class="form-control" id="inputLogin" name="txtLogin" value="SURVEY-">
    </div>
    <div class="form-group">
    <label for="inputPassword">Password</label>
    <input type="password" class="form-control" id="inputPassword" name="txtPassword" placeholder="Password">
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
    }
    </div>

    And now you may login with whatever name and a password with an @ in it and you will see a hanging site. When you don't use a @ you will be redirected to te contact page

    Monday, August 10, 2020 12:32 PM
  • User327468921 posted

    Some sites restrict special character usage in a password. I am sure you have encountered it. Maybe should filter the password usage to not accept an @ sign.  

    Yeah but that would be putting u bucket on the floor when the roof is leaking.. I want to be able to use an @ in a password.. And what if other characters cause something similar? I would like to find out why this hangs..

    Monday, August 10, 2020 12:33 PM
  • User327468921 posted

    I am now talking to another developer in my company and he was running the same simple website and the problem did not occur.. So let me figure out what is different on my computer and his.. Will try some cache deleting, other browser etc.. But this is very strange behavior I never say before.

    Monday, August 10, 2020 1:08 PM
  • User327468921 posted

    Looks like a problem with the Chrome password save mechanisme. I used a real login and password of an existing survey that was saved before and I think that somehow that is the culprit. When I used a new login and password (also with an @ in it) the redirect functioned as expected. When I deleted all saved passwords the problem also disappeared. Also when debugging in other browsers the problem did not appear.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 10, 2020 1:20 PM