locked
Form data always empty in ASP.NET MVC application inside subdomain RRS feed

  • Question

  • User1504334824 posted

    I have two Asp.Net MVC Websites with two different Asp.Net MVC applications running on the same machine. The first one is inside the root domain domain.com, and the second one is a subdomain sub.domain.com.

    Everything works fine inside the root domain, but I'm having trouble submitting forms to every controller on the subdomain using POST. Whatever I try to send seems never to get to the controller.

    It may seem strange but this problem does not happen when I try to start the application locally in debug mode. (locally is not a subdomain, just plain localhost).

    Just for testing purposes I've build a simple model:

    public class TestModel
    {
        public string test_text { get; set; }
    }

    This is the CSHTML partial view:

    @using (Html.BeginForm("TryModel", "Home", FormMethod.Post, new { }))
    {
        <input type="text" name="test_text" />
        <button type="submit">Test</button>
    }

    And this is the test controller:

        [HttpGet]
        public ActionResult TryModel()
        {
            return View();
        }
    
        [HttpPost]
        public ActionResult TryModel(TestModel model)
        {
            // code removed
    
            return View(model);
        }

    Even with this simple configuration, on my local copy I've no problem, but as soon as I start the application on the remote machine, the posted data is always empty.

    I already tried changing the model name and type (using FormCollection), but the data is always empty.

    What do you think could be the problem?

    Thursday, July 2, 2020 7:39 AM

All replies

  • User-474980206 posted

    I would do a network trace to see the post data and any redirects.

    Thursday, July 2, 2020 2:28 PM
  • User1504334824 posted

    I think I cannot do this since because it's on a plesk shared hosting.

    Thursday, July 2, 2020 3:04 PM
  • User-474980206 posted

    You do it from the computer with the browser. You care about what the browser sees.

    Friday, July 3, 2020 2:17 PM