asp.netwebformskenticowebforms-routing

ASP.Net Web Forms - What would cause the form-action to be made relative?


I have a ASP.Net WebForms site (powered by Kentico CMS if that has any bearing) where the URL in the form action is rendered as a relative URL on every page.

Ordinarily I would expect the form action to be an absolute path.

For example, if the page URL is /foo/bar/my-page then I would expect the form action to be /foo/bar/my-page but it's actually rendering as ./my-page.

This is having an adverse effect on pages that use "friendly URLs" via rewriting in Kentico where those URLs have placeholders (i.e. /products/{productcode}/{productname}).

Kentico translates the placeholder values into QueryString parameters under the hood but with the relative URL issue described above it's causing WebForms to append the query parameters to the relative URL

i.e. /products/123/my-product should have the form action /products/123/my-product but is instead being set to ./my-product?productcode=123&productname=my-product which is then causing two instances of productcode and productname to exist in the query paremters... and the postbacks on that page to break.

What would cause this?


Solution

  • Isn't it possible that you have turned off some of the output filters? I was able to reproduce similar issue when the "Excluded output form filter URL" filter was turned off - e.g. using / as the value to turn it off for entire web site. What are the settings of the filters? By default are turned off these filters (with value /): "Excluded XHTML filter URLs" and "Excluded HTML5 filter URLs". Others should be enabled, otherwise you will need to create a custom output filter.