I looked through everything and can not find the answer to this question. I have a simple test controller in ASP.NET MVC4 configured as follows:
public class TestController { [HttpGet] public ActionResult Index() { MyModel model = new MyModel(); model.Debug += "GET Method"; return View(model); } [HttpPost] public ActionResult Post(MyModel model) { model.Debug += "POST Method"; return View("Index", model); } }
The Index view simply has a form and a button that are sent to / Test / Post, which should simply return an HTTP 200 with the Index view. This works on both my laptop and my server. But on the hosting provider, I get the following when I do POST:
POST /Test/Post returns HTTP 302 Redirect to /Test/Post (What the heck?) GET /Test/Post returns HTTP 404
How could this happen? Any ideas on how to fix this?
The only difference I know between environments is that I have .NET 4.5 installed and they have .NET 4.0 installed (and for some reason will not install 4.5.) Projects target .NET 4, though, Think it will make a difference? Initially, they were aimed at 4.5, but changed it after I found out that it was not installed on the server.
Finding ASP.NET POST requests returning 302 raises a lot of login redirection questions. But this controller is not under any limited folder or [Authorize] attribute.
Update - web.config
I tried this with and without <authorization> , the same results anyway. Here is the system.web system if that helps:
<system.web> <customErrors mode="Off"/> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </assemblies> </compilation> <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="30"/> </authentication> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="Database" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/> </providers> </membership> <pages controlRenderingCompatibilityVersion="4.0"> <namespaces> <add namespace="System.Web.Helpers"/> <add namespace="System.Web.Mvc"/> <add namespace="System.Web.Mvc.Ajax"/> <add namespace="System.Web.Mvc.Html"/> <add namespace="System.Web.Routing"/> <add namespace="System.Web.WebPages"/> <add namespace="Microsoft.Web.Mvc"/> <add namespace="Tenido.Domain"/> <add namespace="Tenido.Web.Mvc.Controllers"/> </namespaces> </pages> <httpModules> <add name="ImageResizingModule" type="ImageResizer.InterceptModule"/> </httpModules> </system.web>