问题
I want to implement an admin panel in my ASP.NET MVC Project using "Areas" but I don't have any idea about this.
Please tell me how to implement an admin panel in an ASP.NET MVC Project, either using Controllers or Areas.
Actually I am implementing an ASP.NET MVC Project for a clinic and the client wants to handle all activity through an admin panel. I am beginner doing ASP.NET MVC.
Does anyone know how to do this? Can you please provide me with some tips on how to implement it in ASP.NET?
回答1:
First of all
Areas in ASP.NET MVC are used to group logically related parts together. By creating an area you'll get separate /Contoller
, /Views
and /Model
folders and config file inside the /Area
folder. You'll further have to configure routes for that.
I would recommend you to first create a simple area in your default intranet application. Here is a short tutorial on how to do it.
The admin panel
Now once you have area problem solved then you would probably want to proceed to create admin panel. What I understand from your word "admin panel" is that you want a page against every table in your database to perform CRUD operations on them.
Here you'll need to read the basics of ASP.NET MVC on how to connect to database using ASP.NET MVC. Hint: dbContext.
Create a model for you table in /Models
folder.
Add a Controller in your /Controller
folder. By default there will be an action. You can change its name or create new one.
You can create your Views from scaffolding by right-clicking action name in your controller, here you will have be shown models list to select model for these views, Select the model you created in your /Model
folder.
Continue with
Further I will recommend you grab a book or some video lectures (Scott allen's lecture are pretty good for basic understanding) on ASP.NET MVC and also look for how the admin panels work and what's the best way to create them from scratch.
来源:https://stackoverflow.com/questions/25446464/how-to-make-admin-panel-in-mvc-net