1 Replies - 475 Views - Last Post: 05 May 2017 - 06:16 AM

#1 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6340
  • View blog
  • Posts: 25,565
  • Joined: 12-December 12

Core posting form to area

Posted 05 May 2017 - 06:02 AM

I'm using ASP.NET Core MVC.

I have an Area called Admin and I need my form to post back within the same area. I've tried adding an area attribute (based on searching around and my assumptions):

using (Html.BeginForm("SomeSearch", "Health", FormMethod.Post, new { @class = "form", area="Admin" }))


This doesn't work, leading to a (blank 404) /admin page, nor does the following using a Tag Helper:

<form asp-route-area="Admin" asp-controller="Health" asp-action="SomeSearch" method="post" class="form-group" asp-antiforgery="true">


leading to /Admin.

I thought that adding [Area("Admin")] to the controller would take care of this for me, apparently not ;)/>

Is This A Good Question/Topic? 0
  • +

Replies To: Core posting form to area

#2 andrewsw  Icon User is offline

  • lashings of ginger beer
  • member icon

Reputation: 6340
  • View blog
  • Posts: 25,565
  • Joined: 12-December 12

Re: Core posting form to area

Posted 05 May 2017 - 06:16 AM

Ah, my mistake, nevermind. It works with this

@using (Html.BeginForm("SomeSearch", "Health", FormMethod.Post, new { @class = "form" }))

The other versions may have worked as well. [I had renamed the action method from SomeAdminSearch to SomeSearch but I had only changed this for the get version, not the post version, doi.]

Still, this information may be useful, and it wasn't necessary to explicitly state the Area.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1