asp.net-mvc-routing

Problems with a custom route in ASP.NET-MVC.

I am having problems with Html.ActionLink when I have a route that takes one parameter. I have the following routers in global.asx: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters ...

ASP.net MVC Areas and creating an ActionLink with ID (SEO / clean URL)

Hey Stackers! I am building a Help Desk Ticket system for a client using ASP.NET MVC 1.0 / C#. I have implemented Steven Sanderson's "App Areas in ASP.NET MVC, Take 2" and it is working great. In my Globabl.asax page I have some routes defined as such: public static void RegisterRoutes(RouteCollection routes) { // Routing config ...

Shortening URL params with MVC routing.

I have a url along the lines of this: example.com/profile/publicview?profileKey=5 and I want to shorten it to this with routing example.com/profile/5 How do I do this? This is my attempt: routes.MapRoute( "Profile", "Profile/{profileKey}", new { controller = "Profile", action = "PublicView", profileKey ="" } ); B...

MVC Routing question

I have the following route: routes.MapRoute("Archive", "archive/{year}", new { controller = "Archive", action = "Results" } ); I have the route working correctly, but I would like my url to show as follows: http://mysite.com/archive/2008 when I click on the search button instead of just: http://mysite.com/a...

Routing issue in Asp.Net Mvc

I have a list of puzzles that are tagged with specific "Themes". Think questions on stackoverflow tagged with certain categories. I'm trying to get my route setup so that it works like this: http://www.wikipediamaze.com/puzzles/themed/Movies http://www.wikipediamaze.com/puzzles/themed/Movies,Another-Theme,And-Yet-Another-One My routes...

URL Rewriting with UrlRewriter.Net, ASP.NET MVC Routing or What Do You Recommend?

I'm just wondering, if you are creating a new ASP.NET web forms app in ASP.NET 3.5, which would you recommend for URL rewriting? UrlRewriter.NET or ASP.NET MVC Routing. I've used UrlRewriter.NET before and was pretty happy with it. Opinions anyone? ...

Routing an hiearchical path from DB with ASP.Net MVC

Hi, is it possible to route an hiearchical path to map an relation from the database as follows: Lets say I have an tuple/entity "page" with an m-t-m relation to a "page" (it selfe) and I want to be able to combine the slug-value of each page to find an appropriate page, like so: mydomain.com/firstpage/secondpage/thirdpage where first...

How do I write a link to a static file in ASP.NET MVC?

In my MVC application I have a folder full of PDF documents users should be able to view. However, my links to them don't seem to work: I get a "resource can't be found error". I'm guessing my problem has something to do with routing. What do I need to do so that the browser just renders the documents? ...

asp.net mvc url routing

How do I map something like domain.com/username? The problem is I think that the MVC routing looks for the controller to determine how it should handle the mapping request. I am pretty new to ASP.NET MVC. However, based on the tutorials so far, the routing mechanism seems rather rigid. ...

Full folder path prefixed to application root for MVC at GoDaddy

I am having a similar problem as described here: stackoverflow.com/questions/364637/asp-net-mvc-on-godaddy-not-working-not-primary-domain-deployment I have multiple domains pointing to different folders. Each folder is set as an application root in IIS7 on GoDaddy's shared hosting. These folders are [ContentRoot]/websites/folder1, [C...

ASP.NET MVC custom routes with optional args

I want a Route with two optional args; I thought the following would work: routes.MapRoute( "ProductForm", "products/{action}/{vendor_id}_{category_id}", new { controller = "Products", action = "Index", vendor_id = "", category_id = "" }, new { action = @"Create|Edit" } ); But it only works when both vendor_id and cate...

Remove or replace existing routes in RouteTable

I got a ASP.NET MVC 2.0 Preview 1 app and started to create some areas which contains their own routes. I want to have a way to overwrite these routes in the main project. I can of course not add a new route with the same name. I can see the RouteTable.Routes.Remove(RouteBase item) but not sure how to use it. //Need to remove "PostInde...

How to get Html.BeginForm to GET to correct MVC Route

In my ASP.NET MVC application I have the following GET input field: <% using (Html.BeginForm("Search", "Products", FormMethod.Get) { %> <input type="text" name="searchQuery" id="searchQuery" /> <% } % I want this to go to the route: routes.MapRoute("ProductSearchRoute", "Products/Search/{searchQuery}/{pageNumber}", new...

ASP.NET MVC: action methods with one param not named ID and non-integer

Consider an ASP.NET MVC 1.0 project using the Areas convention as described on this Nov. 2008 Phil Haack blog post. This solution works great once it's set up! My trouble is starting thanks to my limited knowledge of ASP.NET MVC's routing rules. My intention is to create an action method and URL structure like this: http://mysite/...

Can I serve images in ASP.NET MVC application from Views directory

I have some pages designed by someone else as simple HTML that I need to dump into my MVC application. Not surprisingly the images are stored in a local /images directory. I'd like to be able to serve the images up from the Views directory where the main view pages are. I'd rather do this than make it its own virtual directory, but I...

skip or disable links to current path in ASP.NET MVC

I'm writing an helper that basically receives many RouteValueDictionary and returns many links; I'd like to skip links to the current route values (example: in /Products/Details/3 there should not be a link to /Products/Details/3), ignoring other URL params if any. What I can think of is to check if: destination action and controller ...

Basic MVC routing: /FolderName/FolderName/ControllerName

I have a topLevel folder with a subFolder holding ControllerName. When I enter: http://localhost/FolderName/FolderName/ControllerName how do i tell mvc to account for the folder depth? thx ...

href path in aspx files in area

Hi I am continually testing the new feature of ASP.NET MVC 2 Preview 2 called: "Areas within one project". Currently I have a problem with linking to css and js files from within aspx code. When the url points to an url without the id, everything works fine: http://mysite.com/area/controller/action The problem appears when the url...

Can I have more than one "Details" ActionResult in a controller?

I have a Controller called TicketsController.vb, with an action result of: ' ' GET: /Tickets/Details/5 Public Function Details(ByVal id As Integer) As ActionResult ViewData("OpenTixCount") = ticketRepository.countOpenTickets.Count() ViewData("UrgentTixCount") = ticketRepository.countUrgentTickets.Count() ViewData("HighTixCou...

ASP.NET MVC Action Method Parameters from Querystring don't change after first request

I have an action method in a controller that needs to do paging. I am passing a page number and pagesize parameter in the querystring. The problem I am having is that the first request I make sets the parameters for all subsequent calls. public ActionResult GetStuff(string key, int? page, int? pageSize) { // do something magical } M...