routing

Why ASP.NET MVC bothers to have a Default.aspx file?

When create a new ASP.NET MVC project in Visual Studio 2008, there is a Default.aspx page by default. It has one line <%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%> In its Page_Load function, it just redirects to "/" to go thro...

One site, multiple clients ui

I have an Asp.net Mvc site where I want to give a separate access and user interface to different clients like: http://company1.mysite.com http://company2.mysite.com http://company3.mysite.com Each client will have a different ui but practically same functionality (or with some features disabled). I'd like to separate graphics for ea...

Why Change [ ] to be { } in ASP.NET Routing?

I noticed that there is one change about ASP.NET Routing. I cannot understand why such change. In ASP.NET MVC Preview, the routing setting in Global.ascx is like "[controller]/[action]/[id]". Now, it is changed to be "{controller}/{action}/{id}". Why change [] to {} ? Is there some necessity to do that? ...

MVC Routing - Parameter names question.

Hello there! I'm looking for some information on Routing in MVC with C#. I'm currently very aware of the basics of routing in MVC, but what i'm looking for is somewhat difficult to find. Effectively, what I want to find is a way of defining a single route that takes a single parameter. The common examples I have found online is all b...

In IRouteHandler.GetHttpHandler() Can I redirect?

As a glutton for unproven sexy techniques I've adopted System.Web.Routing in my Web Forms application to manage navigation and such. Further, I'm hoping to move role-based security from web.config to the route definitions itself so I can say "this route is only available to roles x, y". So I've got the class that implements IRouteHandl...

Asp.Net MVC routing: best way to have a single element in the URL?

I will take the example of the SO site. To go to the list of questions, the url is www.stackoverflow.com/questions. Behind the scene, this goes to a controller (whose name is unknown) and to one of its actions. Let's say that this is controller=home and action=questions. How to prevent the user to type www.stackoverflow.com/home/questio...

How to redirect to a dynamic login URL in ASP.NET MVC

I'm creating a multi-tenancy web site which hosts pages for clients. The first segment of the URL will be a string which identifies the client, defined in Global.asax using the following URL routing scheme: "{client}/{controller}/{action}/{id}" This works fine, with URLs such as /foo/Home/Index. However, when using the [Authorize]...

How can I get the route name in controller in ASP.NET MVC?

ASP.NET MVC routes have names when mapped: routes.MapRoute( "Debug", // Route name -- how can I use this later???? "debug/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = string.Empty } ); Is there a way to get the route name, e.g. "Debug" in the above example? I'd like to access it in the controller's...

ASP.NET MVC Routes to Mimic Object Graph Traversal?

I'm new to ASP.NET MVC and all tutorials, samples, and the like I seem to find are very basic. Is it possible (and if yes, a good design) to have routes like so: .../Organization/10/User/5/Edit .../Organization/10/User/List In other words; can the urls mirror your domain model? ...

Changeing the ID of a MVC Router from an integer to a string in vb.net

Hi - i'm looking at some pages, and i've noticed that by default for ID in the routing for controller/action/ID is an integer and not a string. How can I change it so it is a string? ...

How to design and implement a simple WCF service relay?

We are in the process of designing a simple service-oriented architecture using WCF as the implementation framework. There are a handful of services that a few applications use. These services are mostly used internally, so a basic authentication and authorization scheme (such as Windows-based) is enough. We want, however, expose some o...

Using a strongly typed ActionLink when the action method doesn't take a primitive type

Hi, Does anyone know how I could go about doing something like : Html.ActionLink(c => c.SomeAction(new MessageObject { Id = 1 } )) This should output a link with the url of "/Controller/SomeAction/1", pointing at an ActionMethod along the lines of: public Controller : Controller { public ActionResult SomeMethod(MessageObject messag...

Routing Issues with MVC Preview 5 and IIS 5.1

Ok so I've spent a couple hours trying to resolve this issue and have had no leads so far, keep getting the same 404 error. What happens is the website picks up the Default.aspx page and displays it like it should. But the Home page has a clickable image where it routes to another view page. The image code is like so: <a href="<%= Url.A...

Deep routes in Zend Framework without modules - how?

I'm writing some routes for a REST service. One of my resource's URI looks like this resources/user/:id I also want to give access to individual attributes of a user, which would look like this resources/user/:id/:attribute But when I try to define that latter route, it doesn't work. Here's my ini where the routes are defined rout...

maproute, querystings and mvc

I have two routes: routes.MapRoute( "FetchVenue", "venue/fetchlike/{q}", new { controller = "venue", action = "fetchlike" } ); routes.MapRoute( "venue", ...

Setting ajax url for jQuery in JS file using ASP.NET MVC

When doing a Ajax call to an MVC action currently I have my javascript inside the View, not inside its own JS file. It is then very easy to do this: var xhr = $.ajax({ url: '<%= Url.Action("DisplayItem","Home") %>/' + el1.siblings("input:hidden").val(), data: { ajax: "Y" }, cache: false, success: function(response) ...

ASP.NET MVC Routing Question

I must be dense. After asking several questions on StackOverflow, I am still at a loss when it comes to grasping the new routing engine provided with ASP.NET MVC. I think I've narrowed down the problem to a very simple one, which, if solved, would probably allow me to solve the rest of my routing issues. So here it is: How would you ...

MVC.Net Routing

Here is my scenario. For the example lets say that I need to return a list of cars based on a search criteria. I would like to have a single View to display the results since the output will be the same, but I need several ways of getting there. For instance, I may have a Form with a textbox to search by year. I may have another sepa...

ASP.Net MVC Routing URL QueryString

Is there a way to link to another View that displays search results without having to use a querystring? For example, I know that I can do the following: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(string txtOrderNumber) { return RedirectToAction("OrderLookup", new { controller = "Report", id = txtOrderNumber }); ...

How to do a custom asp.net routing (hardcoding the controller)

I'm trying to create a route for the following urls: www.mysite.com/user/username www.mysite.com/user/username/pictures I tried doing that with the following code: routes.MapRoute( "UserProfile", "user/{sn}/{action}", new { controller = "User", action = "Index", sn = "" } ); So if an action...