We are using asp.net 4.0 and routing with web forms to create friendly urls.
The routing is working fine except that the correct "action" value is not being assigned to the form element in the master page for any route that has multiple levels.
For example, the route ( customer/{customerid} ) when browsed to with .../customer/12345 only displays 12345 in the "action" attribute of the form. The issue with this is that it isn't complete and any postback fails and gives an error "The HTTP verb POST used to access path is not allowed" If I updates the action as "customer/12345" (using Firebug), the postback works fine.
It even errors when using static routes like customer/customer, it only puts "customer" and not "customer/customer" as the action value of the form. Basically, only putting the last piece of the route into the action attribute instead of the whole route. Why?
Any id开发者_开发知识库eas on how to correct this?
You can work around this by overiding the form action as form1.Action = Request.Url.PathAndQuery;]
in the Page_Load
event
See this related Topic.
It uses Request.RawUrl
instead of Request.Url.PathAndQuery
, which seams to return the same value.
精彩评论