C# - Structuring Of Asp Controller Folders For Better Cohesion?
Oct 1, 2010
When building complex applications the controllers can start to get unwieldy and very large, which may mean that you split them out into separate controllers. This may not be suitable as it will be reflected in the users experience. Ie. They will see the controller name in the URI. For example: The default project that ships with MVC has an AccountController, that has actions for login, logoff, register etc.. which seems to violate the Single Responsibility Principle. So the question is how to resolve this problem and separate out the concerns? An initial response could be just to create separate controllers. Ie.
AccountLoginController
AccountRegisterController
But this would not be a great experience from a customers point of view as it would effect the URI when requesting the resource. A solution could be to have separate folders for each controller which contains separate class files for the action, each one with a single responsibility like so.
The above would separate out the functionality and be highly cohesive. So, this is a long explanation, but my questions are. Has anyone implemented this before? If so how do you go about it? What are your thoughts regarding this pattern?
I want code in VB.NET to create javascript arrays of the folder contents that can then be used on the client end. I only need arrays for all folders contained in folders starting with ad_ and an array for all the base folders . like so:
var folders=["ad_folder","ad_code","ad_prep","ad_bin"]; var ad_folder=["folderA","folderB","folderC","anotherFolder","etcfolder"]; var ad_code=["folderA","folderB"]; var ad_prep=["folderA","etcfolder"]; var ad_bin=["etcfolder"];
note that I do not know the number of or the names of the folders, they can be different in different cases, I only have the root path.
I need some fresh input on how to structure a control panel that I'm building. Here's a little background:
The purpose of the system is to allow the submission of online forms. The forms are stored and processed in a database. Currently there are 3 departments that each have their own set of forms, and each department processes their forms a little differently. The staff should log in and process forms for their respective department (so each department only sees their submissions).
Almost all forms go through a workflow of sorts: 'new submission'-->'in progress'-->'completed', although this may vary.
Right now I've got it mapped out to have a page for each dept. that displays the new submissions, completed forms, etc. (new.aspx, inProgress.aspx, completed.aspx). Here's the question--should I have only one completed.aspx page and use it for all departments (hiding and showing forms based on the employee/department that is logged in), or should I set up three different control panels with three different completed.aspx pages--one for each department?
I have a site I am working on, that will have a home page with a login control. I would expect that after logging in, access is permitted to only certain areas of the website. I would imagine that the properties set by the login control will determine which pages can be viewed. Does this make sense? I know that many other websites have this type of structure, just not sure how it is organized.
UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, that follows the UP(Unified Process). It uses a Grasp Controller pattern to interact with domain classes by some methods like NewSale(), AddNewItemToSale() and CloseSale. In windows form, I can instantiate a object of this class in the UI and then use its methods to perform the actions. This works well in Client apps, but when I use asp.net mvc, I cannot find a way to instantiate an object (one for each user) that was always visible for a Controller (MVC). I cannot insert as an attribute inside Controller because it always create a new one.
my MVC2 delete and only my delete controller is refusing to return any class information. Its really similar to my edit function and the views are all auto-generated so I don't see the problem.
Function Delete(ByVal id As Integer) As ActionResult
I have a simple model where a Person has Gifts. I have a view which is a list of Gifts belonging to one Person.
My problem is with the Create action for a new Gift. I want it to default to the PersonID that we are already viewing the list of Gifts for. I tried simply passing the last PersonID (they are all the same)
Html.ActionLink("Create New", "Create", new { id = Model.Last().PersonID }) which works fine if there is already at least one Gift for that person but if this is the first Gift I don't have a value.
My Gift List controller knows the PersonID I want to pass but the view doesn't.
How do I pass this PersonID from my Gift List controller to my Gift Create controller via the Gift List view? Or is there a better way to do this?
I have a filter on my MVC web site. I display some records in a few different controller actions but when moving from one action to another I want to apply those filter values.
How can I persist values from controller to controller?
Should I use Session? TempData?
I am using Structure Map for IOC.
Maybe I could have a class that contains a Property for each Session Value that I use in my application and inject it on the controllers that need session?
I have a User entity and a department entity. I have a UserViewModel and DepartmentListModel which has List of departments.
UserViewModel has a property of type DepartmentListModel .
Now on user/create action I need to populate DepartmentListModel by calling DepartmentController's list action. List action returns populated DepartmentListViewModel.
From UserController how do I set DepartmentListModel ?
Say I have several Areas that are baed on user roles.Differnet roles have different functionality, but also have some "shared" functionality like say "Payments"Now, I created a PaymentController (and it's views for listing, creating messages) in Shared (not an area) and it works fine.
Would it be possible (and how?) to create a PaymentsController class in one of the Areas, have that inherit the PaymentController Class in Shared?
If I can do this, I can successfully share common functionality across areas, and at the same time extend the derived controller to include some 'area specific' functionality to common shared controllers. (Such as the "REturn to xxxx" text and route of the returnurl, which are a bit more complicated than I just made it sound)
I am just getting started with MVC so pardon the bonehead question, as I am sure that it is one: I understand the conceptual MVC pattern and the basics of routing in the .Net MVC implementation. My first little (VS 2010, Framework 4) project works great, until I get to this: In the project there is a physical folder structure like this :
Each of the folders contains an Index.aspx file (View). I want to link from "~/Views/Recipies/Index.aspx" View to the other Views with something like this:
[Code]....
where I have created an Outdoor controller to handle the Index View. The runtime unfortunately insists on looking for the Index view in "~/Views/Outdoor" rather than in "~/Views/Recipies/Outdoor". I have no doubt that I am falling victim to my years of coding .Net Forms, am missing a link in the chain of conventions relies upon, or some other painfully obvious thing, but I am nonethless stuck.
I was nosing around with Sysinternals Procmon today, just to see where some disk activity was coming from. In the process (pardon the pun) I noticed that Visual Studio was constantly testing for the presence of a bunch of web folders which didn't exist. Procmon log: "D:wwwroot" is my web root. The folder "csharp" doesn't exist.
This happens continually, every few seconds. When I create "csharp" and those subfolders, VS stops checking for them. But they don't exist in my project file and there's no need for them as far as I know. I don't know what they are for. Does anyone know why VS wants those folders? Their absence doesn't seem to affect anything, yet VS keeps checking if they exist, which is weird.
Not quite sure what you would call these but I am looking to create sub folders for my users eg
mysite.com/billyblue
What I have done up to this point is make a 404 page that handles unknown pages. It takes the part after the / and looks it up in the database. Then I redirect them to the relevant page.
I am having a few issues with this and to be honest am not to keen on handling it this way.
Does anyone have an alternative method for achieving this.
I recently upgraded to Windows 7 64 on my development machine. I am trying to setup my development environment. I have discovered something strange. When trying to set breakpoints in my ASP.Net application the breakpoints will only work if they are in the root folder. My ASP.Net project has various sub folders and any breakpoints in code that is stored in the sub folders turns yellow when debugging starts and states breakpoints will be missed.
I have deleted the temporary folder in c:windowsmicrosoft.netframework .... etc. etc. etc. I have checked the folder permissions in the root and all sub folders (they are the same). I have deleted and rebuilt the subfolders. I have right clicked VS2008 and said to run as administrator. Nothing seems to fix it. I can debug root level code behind pages but anything stored in a subfolder will not debug.
I am working on a project where I am using Tree View to display feeds that are available at the start up of the web application. I am also providing the user the opportunity to add new Rss Feeds and categorize them into different folders. When the user clicks on the particular web feed that they want, I need to display it using xmldatasource. When defining the XML Datasource tag and specifically the DataFile property, how can I dynamically pull over the URL based on what the user has selected from the TreeView?
I got one remote website and two local websites. All the .asp files are the same in 3 websites. In the remote website, there is a file aaa.asp, its url is
http://www.xxx.com/aaa.asp
In the first local website, the url of the same file is http://127.0.0.1/local1/aaa.asp
In the second local website, the url of the same file is http://127.0.0.1/local2/aaa.asp
My question is: In any .asp files (may be in different folders) of any above website, how can I get the url of aaa.asp by use the same code?
I'm working on an ASP.NET webapp using the MVP pattern, and as I'm organizing my files I'm wondering - are there conventions on folders within projects and how they relate to namespaces?
I have a bunch of controls and a bunch of pages, and I was going to throw them into Controls and Pages folders with subfolders, but I didn't know if it was bad form to do this if I wasn't also going to seperate them out into namespaces.
I have an ASP.NET website with two different sections, root website and an /Admin sub-folder. I want to have two different forms authentication/login pages for them. /Admin folder should use/redirect /Admin/Login.aspx and root pages should use /Login.aspx. What should I do in web.config to accomplish this?
I have a CruiseControl.Net project set up to build an ASP.Net project, using an <svn> task to pull the latest code from source control.
On a successful build, I use a <buildpublisher> to copy the site to a deployment folder. My problem is that the buildpublisher is copying everything to the destination folder, including every .svn folder and its contents. What is the easiest way to strip out the .svn folders before copying to the deployment folder?
I want to add folders to keep things organized in App_LocalResources. Because when adding a lot of resorce files for different languages in this folder, files are getting messy. I added folders like
FYI : Actually what I did is working. I mean the way I mentioned above is the correct way. The reason why it wasn't working is something else so you can define your folders and the resource files above.