Widget controller postback and route attribute

Aaron Macdonald asked on February 22, 2023 05:18

Hello all

We've had a small feature break in our K13 MVC framework project, for reasons unknown.

The feature performs a postback to a widget controller action, similar to the example below taken from the DG sample site.

[HttpPost]
[ValidateAntiForgeryToken]
[ValidateInput(false)]
public ActionResult Subscribe(SubscribeModel model) { ... }

Some time after the feature passed testing, it then broke and the postback would not work unless we specified a route attribute, as per the updated example below.

[HttpPost]
[ValidateAntiForgeryToken]
[ValidateInput(false)]
[Route("NewsletterSubscriptionWidget/Subscribe")]
public ActionResult Subscribe(SubscribeModel model) { ... }

We'd appreciate any advice on what might have caused this problem. There don't seem to be any changes in the code base that are related, and the route attribute is obviously not required in the DG sample site.

Recent Answers


Liam Goldfinch answered on February 22, 2023 08:27

Has someone changed or removed the Default route being registered?

0 votesVote for this answer Mark as a Correct answer

Aaron Macdonald answered on February 23, 2023 01:13

Hi Liam

That's one of the first things we considered, but it doesn't seem to be the case. Our RouteConfig is effectively the same as the DG sample site with both DefaultRoute and DefaultWithoutLanguagePrefix.

If we omit the aforementioned route attribute, the containing form posts back to the page controller, rather than the targeted component controller.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.