asp.net-mvc-routing

How do I configure ASP.NET MVC routing to hide the controller name on a "home" page?

Following on from this question: ASP.NET MVC Routing with Default Controller I have a similar requirement where my end user doesn't want to see the controller name in the url for the landing or "home page" for their application. I have a controller called DeviceController which I want to be the "home page" controller. This control...

ASP.NET MVC Routing: How do I redirect all actions to Base Url?

Hello! Is there anyway to make all actions in a given controller to redirect to the server root? For example, if I have a URL with controller Home and action terms I want that to the URL to become /terms If I have another URL with controller Home and action privacy, then the URL should become /privacy. I am able to do this by hard-co...

How can I use some kind of IoC (?) to automatically register routes for my ASP.NET MVC controllers?

Currently I've found that it's most convenient to have a separate public static void RegisterRoutes(RouteCollection routes) method on each of my controllers. Then in Global.asax's RegisterRoutes, I call all of these methods. Of course, this is quickly getting out of hand. Every time I add a new controller, I have to go and update Regist...

asp.net mvc routing with optional starting parameter

I'm starting a port of an existing ASP.NET Web Forms CMS to ASP.NET MVC and want to get the routing right from the start. Note: it isn't important to have the exact same URL structure. I think this answer is close to what I'm looking for but would like some additional input should anyone have it. The current URL struction is like: ...

Mapping problem of ASP.NET MVC route with optional URL parameter

routes.MapRoute("Archive.CityState", "Archive/{City}/{State}/{OP1}/{OP2}", new { controller = "Archive", action = "CityState", OP1 = UrlParameter.Optional, OP2 = UrlParameter.Optional }, new { City="[a-zA-Z]+" ,State = @"[a-zA-Z]{2}", OP1 = @"[a-zA-Z]+" , OP2 =@"\d{4}" }); public ActionResult...

ASP.NET MVC Routes Mapping issue

Hi guys, I am struggling with generating outbound urls in asp.net mvc 2. Here is the scenario. Controller: MoveController Action: Index() View: Index.aspx Now what I would like is to have multiple urls mapping to same controller (MoveController) and action (Index) with different parameter (locationId) value e.g. url -> Rout...

ASP.NET MVC - HttpRequestWrapper.Url is null??

My application sends out some emails, and the image paths referenced in the e-mails need to vary depending on how the user accessed the page that is sending the email. I've used variations of the code before many times with no problem, but this is the first time I'm trying to do it in an MVC app: var relImagePath = controllerContext.Htt...

MVC View Bind with form post and display data in the same page.

Hi All, As I have started working on MVC application, I have one query for the same. I have one textbox (for employee name as I want to retrieve data basis on this) in the page , I want to post the form and get result of 'Employees' data in the same form. (I want to show grid type layout in the same form just below to the textbox) Cou...

Global routing parameter in ASP.NET MVC

When a user clicks on a link, I want to log some information. I can't do an AJAX request because if they clicked on a link, the page will unload (since they're going to a new page), and I don't want to force them to stay on the page until a synchronous event finishes. So one idea I had was to add a parameter to the url. I.e. the urls w...

URL from action method name or MethodInfo or something, or listing action routes

I'm trying to document all the actions in my web app, and one of the things I want do is to provide a sample URL for an action. Is there a way to list all the actions in a website along with their routes, or maybe a way to find the route from a MethodInfo? I'm thinking I might have to write a custom attribute for each action to specify...

Problem with multiple ASP.net MVC2 applications on IIS7 ( hosting an MVC app. in another MVC app. )

Hi, what i am trying is the following: I got an MVC app. running DIRECTLY in "Default Web Site"... I got another app. ( ProductionService ) which is anotehr standalone app.. Looks like this in IIS-Manager: My problem is, that a requets to "ProductionService" is not routed to the app., but instead is handled by the MVC-app. runnin...

How to create a custom HandleErrorAttribute that is routed to somewhere other than /Error?

Is there a way to create a custom HandleErrorAttribute that instead of routing users to "Error" instead routes them to something like "Error/Unknown" (where "Error" represents an Error Controller and "Unknown" an action method in it)? Thanks ...

Programatically get controller address of ASP.NET MVC application

Say I want to send an email from my MVC application containing a link back to an item. So I want something in my controller like: string link = "www.mysite/mycontroller/itemdetails/23"; can I retrieve this programatically so it works on whatever server/configuration i happen stick it on? eg string link = GetCurrentActionRoute() + ...

ASP.NET MVC 2 Point Return Links to Appropriate View

The default scaffolded views generated by ASP.NET MVC 2 contain links such as: <%: Html.ActionLink("Back to List", "Index") %> <%: Html.ActionLink("Create New", "Create") %> These links are perfect if I came to this page from that same root. But for example, if I have Orders and Persons and I navigate to /Orders/Edit/17 via /Persons/O...

Help with mapping ActionLinks to Methods in Controllers (ASP.NET MVC2)

I'm on my first MVC project and still haven't got a complete hang of it. I ran into this issue: I have this in my View (Home/Index.aspx) <% using (Html.BeginForm()) { %> <fieldset> <p> <%: Html.TextBox("A")%> <%: Html.TextBox("B") %> <%: Html.ActionLink("Submit", "Create", "Home")%> </p> </fieldset> <% } %> I have this...

Custom routing within an area

Hi, i have an Area called Members and the following registered routes in the MembersAreaRegistration file: context.MapRoute( "Members_Profile", "Members/Profile/{id}", new { controller = "Profile", action = "Index", id = UrlParameter.Optional }, new string[] { "MyProject.Web.Mvc.Areas.Members.Controllers" } );...

ASP.NET routing - avoiding clashes between controller/action and vanity/slug urls

I'm looking for a good solution to having a URL scheme that works for both standard ASP.NET MVC controller/action urls eg: /Home/About --> Controller "Home", Action "About" and vanity/slug urls eg: /fred/post --> Controller "Posts", Action "View", User "fred", Post "post" Importantly, I want the outbound url generation to work so ...

Asp.net MVC custom routing with SEO

routes.MapRoute( "Route", "{id}/{*seostuff}", new {controller = "Home", action="Index", seo = UrlParameter.Optional}); that will allow you to map urls such as http://www.somesite.com/11/whatever/goes-here/will-be-whatever-you/want Here is the original post http://stackoverflow.com/questions/3304645/asp-net-mvc-custom-routin...

Stringlength constraint for route?

Hello I was planning on having 2char language in url, like something.com/EN, /ES, /US. Is that possible to add a 2char constraint for a route? /M ...

T4MVC and Area Routes

Hello, I have the following area route registration method: /// <summary> /// Registers the area. /// </summary> /// <param name="context">The context.</param> public override void RegisterArea(AreaRegistrationContext context) { // terminal customer url context.MapRoute("TerminalCustomer", "Terminal/...