ASP.net 4.0 Webforms Routing Reverse Problem

We use asp.net 4.0 and route web forms to create friendly URLs.

Routing works fine, except that the correct "action" value is not assigned to the form element on the main page for any route that has several levels.

For example, a route (client / {customerid)) when viewed with ... / customer / 12345 displays only 12345 in the "action" attribute of the form. The problem is that it is not complete, and any postback did not work and gives the error message "HTTP POST protocol used to access the path is not allowed." If I update the action as "client / 12345" (using Firebug), the postback works fine.

These are even errors when using static routes, such as client / client, it puts “client” and not “client / client” as the value of the form action. Basically, just put the last fragment of the route in the action attribute instead of the entire route. Why?

Any ideas on how to fix this?

+3
source share
2 answers

You can get around this by overriding the action of the form as form1.Action = Request.Url.PathAndQuery;]in an eventPage_Load

+2
source

See this related topic . It uses Request.RawUrlinstead Request.Url.PathAndQuery, which stitches returns the same value.

0
source

All Articles