asp.net-mvc-routing

How to Route /About to /Home/About

Just getting started with ASP.NET MVC and it's great! But I don't quit understand setting up routes. How do I route ~/About to ~/Home/About? /Views/Home/About.aspx I would like to be able to access it with /Home/About or just /About ...

Html.Action link and Html.RouteLink

Even If the url is same can i go to different action using Html.RouteLink and Action Link.Like when i click on news link i will go to news details.The url of this page is http://localhost:1390/en-US/latestnews/125.Now if i select the ddl of language in the site header in this pagei need to go to the home page of the site.The ddl (on chan...

.net MVC Routing to controller with optional parameters

Hello, i have a quetion about MVC routing. I have a controller method that is called with many different combinations of URL's. To overcome issue i am using optional parameters. here is my controller method signature... public ActionResult localMembersSearch(string Gender, string calling, [Optional]string Region, [Optional]string Coun...

Routing with command controller and sub controllers without using areas

How can I create a routing structure for a project management application where there are discrete controllers for all the relevant pieces such as TaskController, DocumentController etc and an Over arching controller. I would essentially like a structure like: http://server/Project/123/Task http://server/Project/123/Document I am using...

How to use routing in a ASP MVC website to localize in two languages - But keeping exiting URLs

We have a couple ASP MVC websites just using the standard VS templates default settings - Working as wanted. But now I want to localize these website ( They are now in Dutch and I will add the English language ) I would like to use routing and not Resource because: 1. Languages will differ in content, numbers of pages, etc. 2. The conte...

Will the URL /nosuchpage get routed via my ASP.NET MVC application?

[I'm trying to figure out the reason why I'm having another problem, and this question is part of the puzzle.] I have an MVC 2 website that has routing set up so that URLs such as /Customer/23/Order/47 get handled by various controllers. I do not have a rule that would match, for example, /nosuchpage and in my Cassini environment a requ...

How to rewrite a path using a custom HttpHandler

I'm writing a multi-tenant app that will receive requests like http://www.tenant1.com/content/images/logo.gif and http://www.anothertenant.com/content/images/logo.gif. I want the requests to actually map to the folder location /content/tenant1/images/logo.gif and /content/anothertenant/images/logo.gif I'm using asp.net Mvc 2 so I'm sure...

How do I use Asp MVC Url Helpers to generate RESTful links?

I'm trying to use Html.ActionLink to generate a link with in this form: /Action/Model/Id/Parameter1/Parameter2 I've used: <%= Html.ActionLink("Link Text", "Action", "Model", new { id = var, parament1=var1 }, null) %> but it always ends up looking like /Action/Model/Id?parameter1=variable I've seen similar questions on Stackoverflow ...

How to get all active parameters in ASP.NET MVC (2)

Hi! I was wondering whether there is a way to create an ActionLink or similar, that changes only a few parameters of the actual query, and keeps all the other parameters intact. For example if I'm on an URL like http://example.com/Posts/Index?Page=5&amp;OrderBy=Name&amp;OrderDesc=True I want to change only the Page, or OrderBy parameter...

problem with routing/T4MVC Url.Action()

I have these 2 routes : routes.MapRoute("Agenda", ConfigurationManager.AppSettings["eventsUrl"] + "/{year}/{month}", MVC.Events.Index(), new { year = DateTime.Now.Year, month = DateTime.Now.Month }); routes.MapRoute("AgendaDetail", ConfigurationManager.AppSettings["eventsUrl"] + "/{year}/{month}/{day}", MVC.Events.Detail(), new { year =...

How do link the first level like localhost/About and localhost/Faq.

I make Views/About/Index.aspx and Views/Faq/Index.aspx + Controllers/AboutController.cs and Controllers/FaqController.cs controllers for these purposes. I want to have one controller Controllers/DefaultController.cs + Views/About.aspx and Views/Faq.aspx in the root, for example. How to set it up? ...

ActionLink in Asp.Net Mvc 2 does not reidrect

I have the following default and only route: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); In my Site.Master I have the following: <%= Html.ActionLink("Profile", "Details", "Use...

MVCContrib Testing Route with Areas

Hi, I am using MVC 2 with Area. To test routing, I am using MvcContrib. This is the testing code: [Test] public void Home() { MvcApplication.RegisterRoutes(RouteTable.Routes); "~/".ShouldMapTo(x => x.Login("Nps")); } I am not sure how to call routing definition that are stored in Areas. Calling AreaRegistration.RegisterAllAre...

MVC Site - Ensuring the default entry view is always correct

I have a MVC site with AD authorization. This is all working fine. I publish the site to the webserver and call the site directly (http://intranet). If I have not logged in for a while (I have an authorised cookie with a 30 minute TTL), I am prompted to log-in and if successful I am redirected to the homeController's index view. This...

ASP.NET MVC Areas: How to hide "Area" name in URL?

When running the MVC 2 Areas example that has a Blog Area and Blog Controller the URL looks like this: http://localhost:50526/Blog/Blog/ShowRecent in the format: RootUrl / AreaName / ControllerName / ActionName Having just discovered MVC Areas, it seem like a great way to organise code, ie create an Area for each section, which in m...

Having all Views in the Shared folder - works but is throwing "caught exceptions". Performance concern??

Hi everyone, I have a simple but heavily used app done in VS2010/MVC2. I didn't like having separate folders for each view/controller and so have all the views in the Shared folder. It's working fine but while debugging in VS, I noticed that it's throwing IO "caught exceptions" since it seems to be looking in the [FolderName]/[ViewNam...

Invoking a ASP.NET MVC controller from a request handler with more than one parameter as data

I am working on building an MVC frontend for a CMS system. The CMS system will serve ASP.NET MVC with pages and content. In Global.asax I registered a custom route handler like this: public class MvcApplication : EPiServer.Global { public static void RegisterRoutes(RouteCollection routes) { routes.Add(new Route("{*data}...

How can I get controller type and action info from a url or from route data?

How can I get the controller action (method) and controller type that will be called, given the System.Web.Routing.RouteData? My scenario is this - I want to be able to do perform certain actions (or not) in the OnActionExecuting method for an action. However, I will often want to know not the current action, but the "root" action bein...

ASP.NET MVC Routes

Can I see one example that would make this piece of code compile? public IEnumerable<RouteBase> Routes { get { return new List<Route>() { new Route(...) } } } What would you do if RouteCollection.MapRoute() didn't exist? I'm trying to put my Contr...

RouteTable.Routes.GetVirtualPath with route data asp.net MVC 2

Dear all, I'm trying to get a URL from my routes table. Here is the method. private static void RedirectToRoute(ActionExecutingContext context, string param) { var actionName = context.ActionDescriptor.ActionName; var controllerName = context.ActionDescriptor.ControllerDescriptor.ControllerName; var rc = n...