简体   繁体   中英

<form asp-action in areas. Can`t find a controller. Asp.Net Core

I have one form in a page in the main area. Views/Home. Code and I want that you see the screenshot.

在此处输入图片说明

VS make a color for this form. And it is working with controller

<form asp-action="LoadImg" asp-controller="Account" method="post" enctype="multipart/form-data">
<input type="file" name="ImgPost" /><br>
<input type="submit" value="Загрузить" />

Next, I want to make the same but in Areas/Admin/Views/Home/Private and I see next

在此处输入图片说明

First of all, I want to know why the color in VS is different? And why when I click submit it isn't going to my controller in Areas/Admin/Controllers/Home/Load - action

as usual, I use in areas Razor and its working. It is example of the same page in areas @using (Html.BeginForm("PostSave", "Home", FormMethod.Post))

  1. Why I have diferent colors in main area and admin area and how to find controller in area by this way <form asp-action="Load" asp-controller="Home" method="post" enctype="multipart/form-data">

Thanks

It sounds like VS intellisense isn't loading your tag helpers for your MVC area. You can register the tag helpers explicitly in your view by adding the following line at the top:

using @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Alternatively add a _ViewImports.cshtml containing this line to your area, or copy the one from your main ~/Views folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM