MVC :: How To Organize More Complex Routes

Mar 12, 2011

I understand the basics of setting up routes, I am trying to get a handle on how to organize more complex routes. Does the Route name do anything? I havn't seen a place it's actually used. If I have the route: controller/action/id/paramA/paramB/paramC. ParamA-C could be defining multiple parameters so First/Last/Zip or Phone/Zip/Birthday. Is it common practice to name the additional parameters with a generic name like paramA vs trying to differentiate a separate route for each?

Lastly, if you have multiple sites/functional areas in 1 site, lets say the asp.net site, each area MVC, Ajax, Forums ect were all different functional areas. Is it best to create a different group of routes such as hard coding the controller like:

MVC/action/id
Ajax/action/id
Forums/action/id

or is there a better way? What I am running into is 1 piece of the site overriding the other route because of the number/type of parameters.

View 5 Replies


Similar Messages:

MVC :: Routes.IgnoreRoute Not Ignoring Routes?

May 25, 2010

I'm trying to prevent direct file requests from being accepted, and have tried this:

[Code]....

None of these worked. I want the rule to exclude any file of any filename in any directory with a matching extension. How can this be done?

View 11 Replies

How To Mix DynamicData Routes With Mvc Routes

Jan 9, 2011

I am trying to create an Area for running DynamicData with scaffolding as an administration part. It's probably working as it should but I can't get the routing to work.

In my global.asax I have the following function to register the routes:

[Code]....

Unfortunately the "best" thing that happened to me so far was that when I check the default tables I get a message about (MetaModel.VisibleTables)

[Code]....

The problem is that I don't know why this is. Is it the routing or something else? Is it perhaps some security thing or can I not put dynamic data inside an area?

The DynamicData folder itself is located in the root of the application since that is the convention it uses and I have no intention to override that.

View 1 Replies

MVC :: How To Organize An Application

Apr 9, 2010

I'm building ASP.Net MVC 2 application using Repository pattern. My question is how to organize my application. Most of the examples I see on the web, using separate Modelproject with Repositories and Entity Data Model. These examples are not using MVC Model folder.

I have 3 projects in my solution.

1. Application (MVC Project)

- Models

- Repository (Here I want to create Repository folder for my Repository)

- IRepository (Also I want to create IRepository folder for my Interface)

2. DataModel ( Which will have my Entity Data Model and my POCO T4 Template)

3. Test

View 5 Replies

C# - Name And Organize CLASS Files?

Nov 11, 2010

I use ASP.NET in C#, I am pretty new at developing so I would like have some advice from experts :-).uestions:What is the best ractice to organizing CLASS FILES?What kind of name do you use?For Web Application Project, how do you name NAMESPACE?In my Case I am building a simple CMS. I thought the FILE structure like this:

- AppCode
- Common
- UserDataInput.cs
- ExternalLibrary
[code]...

View 1 Replies

How To Organize Code Within An Application (sub Folders)

Jan 23, 2011

In a website, I see some developers put code into app_code, and sometimes appcode (due to some bug), other files into DataModel, and other files into miscellaneous folders.

Is there a standard approach to organizing code within an application?

How is it different between an ASP.NET, MVC, Silverlight, Console, Database, and WCF application? The reason I mention WCF is because many people seem to have a shared types library that is linked between the server and client code.

Where can I learn these common practices without having to try, fail, and try again. I'd rather just learn it once from the experts.

View 3 Replies

How To Organize And Manipulate Pictures In Filesystem

Aug 26, 2010

Although it may not seem like that but there is a little questions about this subject.I am not asking if I should use DB or filesystem, the file system it is, but I am asking what is the best way of organizing pictures in file system that will be used with asp.net application? I am talking about tens or even hundreds of thousands of picture.

To elaborate a question a bit.

Where should repository be located, create another VD in IIS or in application VD, or somewhere outside IIS?
How to organize file patsh, put them all in one folder or create subfolders. If so how to name all those folders?How to handle multiple sizes of the same image? where to locate them?How to sync folders and images with database?What else crosses your mind, and you think it's important..

I've done something myself allready, but I am asking if someone had some experience with this. Maybe it could be done better yours way.

I put things like this

I stored pictures in IIS folder, because storing them outside of iis make them unable to use in web, because of paths. You cannot use file path in web, it must be virtual file path.

http://images/1.jpg istead of C:images1.jpg
in the root I had subfolder for each picture size

root-
+400x300
+600x400
+1024x768

Named images by id from database. If the ImageID from database is 45678909, the name of picture is 45678909.jpg an it's location is

VDimages400x30045678945678909.jpg
VDimages600x40045678945678909.jpg

I sliced the picture name two by two, and create subfolders. the point was not to have more than 100 files in folder. Was this good idea or stupid one? How would you organize this? For person, this organization with tons of folder is not easy to use.

Name of the image with its relative path I saved in database table with description and time of insert etc. path: 45678945678909.jpg

View 2 Replies

How To Create Folders To Organize Web Sites In IIS7

Apr 20, 2010

I have several ASP.NET sites in IIS7 and would like to be able to group them into folders (or other mechanism, if available). Ideally, I would use a customer name or account number and put the sites under there.

Is there a way to customize the organization of sites in IIS7, or is there just the one 'flat' view?

I'm open to tricks and hacks.

View 1 Replies

How To Organize Web Application Project In Visual Studio

Jan 31, 2011

+1 if you are specific to ASP.NET MVC projects.

Update 9:42 PM:

I am thinking about this from now as I need several developers across the globe to work on this project. We will be using VS 2010 and I heard some thing about web application templates.

View 2 Replies

C# - How To Organize Code (methods I Create For Various Uses On My Website)

Oct 14, 2010

I wrote some code to connect the application to it's database, then I created some code to use the connection code and retrieve, update or add some values to the database, Also I might have some code to deal with other stuff than to deal with the database

The code is a little complicated, maybe it's simple but it's not short, for example to write a good piece of code to just retrieve a single value so I could set the controller with this value I used this :

SqlConnection sqlconnection= new SqlConnection(ConfigurationManager.ConnectionStrings["DefConnectionString"].ConnectionString);
SqlCommand sqlcommand = new SqlCommand("SELECT name FROM message WHERE id = 3", sqlconnection);
try
{
sqlconnection.Open();
lbl_name.Text = (string)sqlcommand.ExecuteScalar();
Status.Text = "Done";
}
catch (Exception ex)
{
Status.Text = ex.Message;
}
finally
{
sqlconnection.Close();
}

I might even add some code to store some info in the database about any exception is thrown, I think the code is pretty basic, yet it's not small, given that it's the smallest piece I'll need, some huge code is written for adding or editing new items, and also consider that it's not the only code I'll write in the page, the page has more needs.

I've provided a detailed case I hope!...So what do you think will be the best way to make my page fast and easy to read and have an organized code I've started placing every code in an appropriate method, but some methods are common so I create them again in every page that needs them like a ConnectionToDataBase Method, and mean while I think I just organized the page so I could mainly look at Page_Load and see what are the called methods and then scroll down to read the definition but It's still a big page and note the best practice I think

Sorry for all the big question, I just provide details so I could get a reasonable answer for my question, I hope everyone benefits from it as most questions are pretty basic, newbies like me needs some detailed cases and answers to get a better start.

EDIT: I know I'm new, So any comments on my code are more than welcome!

View 1 Replies

MVC - How To Organize Commonly Used Drop-down Lists In Many Views

Jan 8, 2010

I am trying to understand how best to organize some common Dropdown lists used in several views (some are cascading)

Is it best to create a single ModelsCommonQueries then create a webservice for each dropdown used in cascading situation then have a single controller that contains actions for each dropdowns

This way I can follow DRY principle and not repeat the dropdown logics since they are used in various views.

View 1 Replies

Tool To Properly Organize Tag Attributes For Asp Files?

Jan 8, 2010

I realize that VS200X can ident asp files properly, however, for the sake of ease in finding attributes, is there a tool that will also organize the attribute order within a tag alphabetically? I'm always scanning around a tag visually and if the attributes were sorted alphabetically, asides maybe from ID and runat which should remain first, I would have a much easier time.

View 2 Replies

Jquery - Best Way To Organize Files In A Large MVC2 Project?

Jan 27, 2011

I've looked all over the web for the best way to organize an ASP.NET MVC2 project. I've only seen examples of people using the default template for MVC2 projects. But is this the best way to organize your project if it is going to contain a large number of files?

We're in the process of building an application that is heavily built around jQuery for UI and ajax using JSON. So, as you can imagine, we will have many custom .js support scripts.

In our solution, we have placed all our support libraries (3rd party and custom) into respective projects. The MVC2 project that is also in the solution is using the default MVC2 template.

In the MVC2 project, the "starting" structure is still pretty much unchanged. Under the Controllers directory, we have each controller AccountController.cs and HomeController.cs (for example). Under the Views directory, we have three subdirectories named Account, Home, and Shared. In the Scripts, directory we have also divided that up with three directories, Account, Home, and Shared. And finally we have the Models directory, that is also divided into Account, Home, and Shared subdirectories.

As you can see we haven't deviated from the basic template that much. But, as we start adding stuff to this, we're realizing how cumbersome this might become when we get upwards to 20 or 30 views and 100 support .js files.

View 1 Replies

Organize Code Outside The App_Code Directory Or Into Separate Projects?

Feb 25, 2011

I've been working with MVC for awhile and I'm not sure what works with asp.net.

Is it possible to organize code outside the App_Code directory or into separate projects? How would this be done?

View 2 Replies

Mixing Application Modules - Organize The Silverlight Project?

May 5, 2010

I work in a suite of ASP.NET applications that have several different "modules". The applications all share a main menu, so they all link to one-another. The modules are the high-level areas of the application. So, for example, it might be Payments, Orders, Customers, Products, etc. And Payments and Orders are in one app and Products and Customers are in another. Some of these menu links are "deep links", for example it might be a link to a particular page within the Customers module, such as Create New Customer.

We are about to start a project that will add several more modules to this suite, probably as a new .NET application. I'm thinking about doing these new modules in Silverlight (for various reasons that are not material to the question). If I were to do that, I need to make the menu look the same as the menu in ASP.NET, as the users still need to feel like they are inside one "application".

How should I organize the Silverlight project(s) so that I can "deep link" from ASP.NET pages into particular modules in the Silverlight app? What is even the best idea for creating these different Silverlight "modules"? If I had something that would've been a page in ASP.NET (for example - Create Customer), should each one of those be a separate Silverlight app? Or should it be a separate User Control? Or something else? Should I reuse our shared ASP.NET menu, and deep link to different Silverlight "modules" even within the new application? Or should I reimplement the menu in Silverlight for navigation within the app? Are there menu controls for Silverlight that look similar to ASP.NET menus (with flyout submenus in this case)? Could I maybe even share a SiteMap XML file between them?

View 1 Replies

Security :: Want To Organize Twenty-four-hour Local Network Monitoring?

Jun 16, 2010

I want to organize twenty-four-hour local network monitoring. Could you tell me about such program? The program has to ping hosts and save results in files on hard drive for viewing.

View 3 Replies

How To Organize The Work After Project Needs To Be Re-implemented Due To Poor Code Quality

Apr 28, 2010

I have been asked to join a very small team where one main developer has been buiding the web app (.NET 4.0) during ~6 months. The project should be delivered within next 2 months.

After first look at the code I can say that I would never allow it to go to production (things like catch { }, no tests at all with WebForms etc).

So the code quality is incredibly low.

My task is to improve that and still deliver the solution. So I plan to start with unit testing and MVC2 reimplementing most of the functionality (though using some of the existing code).

I estimate that I will need about 6 weeks to catch up with the current progress and be on te same functionality level as the application will be in 6 weeks.

The problem is that the main developer who has been working on the project seems to be really starting in IT and many basic things are unknown to him. It will take significant amount of time and effort to educate him how to do the proper testing, development and apply some patterns.

I am ready to take responsibility for the reimplemnting the application but at the same time I don't want the main developer to be on idle but as he won't be able to significantly contribute to the better-world project at this stage I am not sure what would the best way to keep productivity high for both of us.

Currently I think following solution is good enough: He proceeds doing what he does until I will catch up with him and then start working on a new project together.

The problem is that of course this approach is not very productive as one developer will do better-world project while the other will proceed with what he did, effectively doing similar tasks.

Another approach would be to pair and try to do things together, but again not sure how productive we will be.

Can you suggest how we could better organise the work together in order to be most efficient for the overall project?

View 3 Replies

WebMatrix :: Use @foreach To Organize Limited Preview Rows And Displays The Page Number?

Mar 9, 2011

the helper @grid.GetHtml() You can display the limit rows (e.g. 10) and page numbers at the bottom of the display which can be viewed by clicking on the following sample data.But the helper @ grd.GetHtml() (I figured) there are restrictions in output. For example if I want to display picture < img src =" @ id .jpg" alt = ""/> (I'm doing when working with @ foreach) to do that I need to put in the < img src = ".jpg" alt = ""/> it's not convenient. mene Is it possible to use @foreach to organize limited preview rows and displays the page number to view the data?

[Code]....

View 2 Replies

MVC :: 2.0 Messing Up Routes In ARR 2.0

Dec 28, 2010

I have a server that has been using ARR 2.0 on IIS 7. I recently added MVC 2.0 to my ASP.NET site. After adding it the ARR routes return the following error: The virtual path 'null' maps to another application, which is not allowed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: The virtual path 'null' maps to another application, which is not allowed. Source Error:

[Code]....

Stack Trace:

[Code]....

In my web.config I can remove the modules attribute runAllManagedModulesForAllRequests and the ARR works, but it makes the MVC routes stop working.

View 2 Replies

MVC :: Routes Error In 2 RTM

Apr 3, 2010

I created an MVC 2 RTM Project and created 2 Areas (Admin and Applicants) The code belows was added into the global.asax: AreaRegistration.RegisterAllAreas(); I also ensured that duplicate Controllers were managed as i have a homecontroller in the root and the Admin Area. The code used was; new string [] {"MyAppName.Controllers"} This too went into the global.asax The error i got is below; A route named 'Applicants_default is already in the route collection. Route names must be unique. Parameter name: name how to resolve this?

View 6 Replies

MVC :: ViewBag And Routes (3 - RC2)

Dec 18, 2010

I am having an issue with MVC-3 generating outgoing routes for me. This is the address of the page I am on for both scenarios: [URL] Here are the map routes:

[Code]....

Scenario 1:
From the controller:
[Code]....
From the view:
[Code]....

The resulting link that gets created. [URL] If I change the controller code to read as follows:

[Code]....

I didn't make any changes in the view, only added those two lines to the controller and the following link is created: [URL] What am I missing here? This is consistent behavior, I was able to reproduce this in other areas of my application.

View 4 Replies

C# - Routes With Multiple Arguments In MVC 3?

Jan 19, 2011

I am trying to set up dynamic routes in an MVC app, and I have this so far...

[Code]....

And that is working great for now, the only issue I am having is that I would like to have the ability to specify a comma delimited list of optional arguments in the database that I could pull out like...

Array optParams = rdr["parametersOpt"].ToString().Split(',');

But I was not sure how to stick those params into the route object properly. Could just be a minor C# syntax I am not familiar with.

View 2 Replies

MVC :: Database Localization Url Routes With 2?

Jan 19, 2011

I been looking for hours on the web to find a good tutorial where I can do a database localization with mvc 2, I can't find any its all resource files. So I'm trying to reach out to you guys and see if you got any links, books or suggestions on this topic? I would love for it to be url routes based localization but that I can figure out somehow i think.

View 10 Replies

MVC :: Custom Routes For 5 Different ActionResult()?

Apr 6, 2010

I'm creating a new ASP.NET MVC 2.0 web application that will have 5 main pages:


- Home
- Services
- Contact Us
- Terms & Conditions
- Priva

View 2 Replies

MVC :: Adding Routes - Best Practices?

Jul 4, 2010

We are working on a project which has lots of routes that can be changed on-the-fly or new routes can be added dynamically. What are the best practices about managing lots of routes and adding routes on-the-fly without recompiling? Reading-Writing from-to database or from Xml Document in Application_Start?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved