asp.net-mvc-routing

Doesn't ASP.Net MVC Differentiate URLs on number of arguments?

Somehow I had the impression that ASP.Net differentiates URLs based on the number of arguments too. But it doesn't seem to work in my project. Consider the following function prototypes public PartialViewResult GetMorePosts(string param1, string param2, string param3, int param4, int param5) AND public PartialViewResult GetMorePosts(st...

In ASP.NET MVC, how can I rewrite from /somepage to /pages/showpage/somepage?

How can I rewrite a url like: /SomePage to /Pages/ShowPage/SomePage? I tried: routes.MapRoute("myroute", "{id}", new { controller = "Pages", action = "ShowPage" }); But It's not working. What am I doing wrong? ...

Can ASP.Net MVC routing account for a "OR" option?

I have this routing setup at the moment routes.MapRoute( "OldPages", // Route name "page{id}.html", // URL with parameters new { controller = "WebPage", action = "Details", pageName = "oldpage", moreInfoID = 0 }, new { action = "Details" } ); ...

Correct Controller code for a 301 Redirect

I am designing a new dynamic site from a static site. I have the route all sorted but I have a question on my Action method. Below is the code but when testing and looking at the headers that Firebug reports, if I take out the Response.End it is a 302 redirect I assume because I set the 301 but then call another action which makes it a...

How do I route the default debug path to the actual path in asp.net mvc?

When I click run on my vs2008 to try out a page it tries to load http://localhost:14092/Views/Employee/Index.aspx which should be http://localhost:14092/Employee/Index or http://localhost:14092/ How do I add these 2 routes? (I want to know how to do both so I can swap them as desired. Here's my current routing code: public stati...

Setup a route {tenant}/{controller}/{action}/{id} with ASP.NET MVC?

I would like to setup a multi-tenant ASP.NET MVC app. Ideally, this app would have a route with {tenant}/{controller}/{action}/{id}, each tenant representing an logical instance of the app (simply independent multi-user accounts) The fine grained details how do that are still quite unclear to me. Any guide available to setup such multi-...

asp.net mvc id not being pulled from route?

I'm not doing any fancy route patterns yet, just the basic controller, action, id style. However, my actions never seem to be passed the id. When I stick a breakpoint in any one of my actions, the value of the id parameter is null. What gives? Global.asax.cs: public class MvcApplication : System.Web.HttpApplication { public static...

Compare two RouteValueDictionary instances

I am writing a helper for my application which writes out a menu item for a given strongly typed controller/action as follows: <%= Html.MenuLink<WhateverController>(c => c.WhateverAction(), "Whatever") %> As part of this process, I would like to apply the class of active to the outputted link if the current page and the page linked to...

Render Partial ViewData Parent/Child

I have a collection of Shelves and each shelf has a collection of products. To optimize reuse I have created a partial view ProductList.ascx that is called as I loop through the list of Shelves. In the partial view I want to have an Add link for each type of product, and need the Shelf Id to do so. Since the partial view is a collecti...

Designing MVC URL scheme for hierarchical system

So imagine I'm building a Multi User Dungeon system using a MVC web application. To describe the areas the player can explore, the system can contain a number of Maps, which will consist of Rooms and Doors - where doors connect two Rooms. Consider the authoring part of the system. To create a Map is easy - I need URLs like: /Author/Map...

ASP.NET MVC route returning 404 without action

I am working on a very simple application, using MVC2 Preview 1. I have a controller named ContentController. My problem is that /Content/Index works correctly, but /Content/ returns a 404. I am running the application on the Studio Development Server. Tested with RouteDebugger but /Content/ returns a 404, and does not display any debu...

Gradually migrating Classic ASP 3.0 to ASP.NET MVC

I'm evaluating a migration from a classic ASP 3.0 application to ASP.NET MVC. I've already migrated applications to WebForms, but have decided to try MVC for this migration for a number of reasons, including the fact the code in this application is NOT spaghetti and seems to lend itself to an MVC style layout. One major constraint on th...

ASP.Net MVC RouteData and arrays

If I have an Action like this: public ActionResult DoStuff(List<string> stuff) { ... ViewData["stuff"] = stuff; ... return View(); } I can hit it with the following URL: http://mymvcapp.com/controller/DoStuff?stuff=hello&amp;stuff=world&amp;stuff=foo&amp;stuff=bar But in my ViewPage, I have this code: <%= Html.ActionLi...

Url.Action and routeValues inheritance

Suppose I have the following route. routes.MapRoute("SomeRouteName" , "{node}/{action}/{destination}" , new { Controller = "Document"} , new { Action = "Transfer|Destine|Remove" } ); When "/X/Destine/Y" URL is entered, the "Destine" action fires and renders a view, which contains the following: <%= Url.Action("Transfer") ...

Trouble redirecting string[]

I have a form that posts several like named elements to an action like so: <%= Html.TextBox("foo") %> <%= Html.TextBox("foo") %> <%= Html.TextBox("foo") %> posts to and returns: public ActionResult GetValues(string[] foo) { //code return RedirectToAction("Results", new { foo = foo }) } the "Results" action then looks like ...

Images not showing depending on the URL: with or without dash "/" in the end

Hello mates, This is really weird. The images of my website are not showing properly. If a add a slash in the end of the url, they show up, otherwise, they don't. Take a look: This is the link with dash in the end: http://jobbox.com.br/cocoonhealth/insurance/private-health-insurance/ To see the issue, delete the dash in the end…. the ...

Mixing ASP.NET MVC into ASP.NET WebForms

For some reason my routing is ignoring any attempt to access my MVC pages and simply giving me 404s. I have a WebForms app set up like the following: Virtual Directory: thing So I usually access my site like so: http://localhost/thing/someFile.aspx http://localhost/thing/someFolder/anotherFile.aspx The original stucture of my A...

MVC Routing - Tagging model items to specific routes

Hi, Just wondering if anyone has advice on tagging items to specific routes. For example, if I have 2 items, they're of the same model type however I want one of the items to have a route. "folder1/folder2/{ItemName}" and the other to have a route "folder3/folder4/{ItemName}" So I want to specify that item one is only viewable thr...

How to do long static urls in asp.net mvc

Hi, what would be the best way to create long static urls in asp.net MVC? For example say I wanted to create the following url. Ex: /Packages/Somepackage/package a ...

Is it possible to redirect content calls in ASP.NET?

I'm experimenting with javascript and css caching in ASP.NET MVC. Is it possible to intercept calls to the server for these types of files? For example, if a request gets to the server for ~/Scripts/Something.CurrentVersion.js I would like to intercept this call and tell the server to return ~/Scripts/SomeOtherFile.js Would it be p...