Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Microsoft Bugs when using MVC in Area

$
0
0

Hi,

I am using AspNetCore 1.0.0 RTM, I have encountered couple bugs when I used Area. The Area in my project structure looks like this

MyProject => Area => Admin => Controllers

1. When I right click the Controllers folder above and choose "Add => Controller", then choose "MVC Controller with Views, using Entity Framework", click "Add" button. then I choose a "model class" and a "Data Context Class", click the "Add" button. The scaffolding will create a ProductsController class in the right place. However, the view classes it created will be inside the

MyProject => Views => Products

folder. Not the supposed

MyProject => Area => Admin =>Views => Products folder

2.Since I can't use the scaffolding, I would have to add view files one by one myself. So I created a "Views" folder under the

MyProject => Area => Admin

Now I manually added CRUD files one by one.  Right click "MyProject => Area => Admin =>Views" add a new folder "Products". Then right click this "Products" folder, "Add" "View", enter a name such as Index, choose "List" from the template, choose a model class from the drop down. click the "Add" button. The Index.cshtml file created from this scaffolding will not be correctly processed by the MVC engine, however. What I mean is, for example, in line 10, there is a

<a asp-action="Create">Create New</a>

this code won't be processed by the MVC engine. When I start the project (Ctrl + F5) and go to

http://localhost:61496/admin/products

the above "Create New" is not a link. In another word, the MVC didn't change

<a asp-action="Create">Create New</a>

to

<a href="admin/Products/Create">Create New</a>

You can verify it by right clicking the browser, choose "View Source".

3.Furthermore, even if I went into the "MyProject => Area => Admin =>Views => Products => Index.cshtml", and manually change the above link

<a asp-action="Create">Create New</a>

to

<a asp-area="admin" asp-controller="products" asp-action="Create">Create New</a>

the link is still not generated. This is totally against what the Area tutorial says here

 

https://docs.asp.net/en/latest/mvc/controllers/areas.html


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>