1

I have next specific map routes

routes.MapRoute(
             "MyPagePost",
             "URL-Up/{name}",
               new { controller = "MyController", action = "MyPostAction" },
               new { httpMethod = new HttpMethodConstraint("POST") }
                );

            routes.MapRoute(
                "MyPageGet",
                "URL-Up/{name}",
                  new { controller = "MyController", action = "MyGetAction" },
                  new { name = "[A-Za-z].+", httpMethod = new HttpMethodConstraint("GET") }
           );

my default controller looks like

routes.MapRoute(
                name: "Default",
                url: "{culture}/{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", culture = "en", id = UrlParameter.Optional },
                constraints: new { culture = @"[a-zA-Z]{2}" }
                );

and the issue is next: my get MyPageGet route show a page with include FORM with POST reqvest to MyPagePost route, but on a first call I am getting the same GET request and see in URL other extra param ?culture=de. Moreover, with or without this parameter, second call it working fine via MyPagePost route.

UPDATE: In Chrome or fiddler Logs I see that reqvest to URL-Up/Bla-Bla has 302 status and response heared is URL-Up/Bla-Bla?culture=de. Why it can't be processed ?

1 Answer 1

2

just try it with

@using(Html.BeginRouteForm("MyPagePost",FormMethod.Post))
{
     <input type="submit" value="Submit"/>
}

The routes in your post working for me in both html.beginform and html.beginrouteform on the first time.

i try it with the following routes and action methods

      routes.MapRoute(
          "MyPagePost",
          "URL-Up/{name}",
            new { controller = "Home", action = "PostAction" },
            new { name="[A-Za-z].+", httpMethod = new HttpMethodConstraint("POST") }
             );

        routes.MapRoute(
            "MyPageGet",
            "URL-Up/{name}",
              new { controller = "Home", action = "GetAction" },
              new { name = "[A-Za-z].+", httpMethod = new HttpMethodConstraint("GET") }
       );

        routes.MapRoute(
             name: "Default",
             url: "{culture}/{controller}/{action}/{id}",
             defaults: new { controller = "Home", action = "Index", culture = "en", id = UrlParameter.Optional },
             constraints: new { culture = @"[a-zA-Z]{2}" }
             );

           public ActionResult GetAction()
    {
        return View();
    }

    [HttpPost]
    public ActionResult PostAction()
    {
        return View();
    }
Sign up to request clarification or add additional context in comments.

2 Comments

the result is the same
after different way I finally epiphany solve the issue I write the same controller method name MyGetAction with httppost attribute and it is working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.