asp.net-mvc-routing

MVC:RESTful routing with nested urls, when entities are not really nested

I 'm really having a hard time with the RESTful paradigm + nested urls. I have asked a question that lead me to where I am right now here. My Domain is roughly this: there are schools, courses of a school and teachers of schools. Now schools, courses and teacher are not "nested" entities in the sense that you can refer to any of them wit...

ASP.NET MVC: Controlling naming conventions of controllers / views?

Hi there, Can anyone tell me how i can manually edit my naming convention of my routes.. Let me explain. I am programming everything in english as per microsoft standards but i require www.mydomain.com/Reserva (Spanish for reservation) I actually have the following ReservationController and then below views i have a folder called...

How to get the physical folder of the current view with ASP.NET MVC?

I have a separate utility class that is called in the controller, and i need to access a file inside the Views folder. Inside the the Views{controller} are a couple of sub folders that contain the different views. What I'm looking for is something similar to using: HttpContext.Current.Request.PhysicalApplicationPath to get the physic...

ASP.NET MVC: Uri to usable route data

My problem is pretty simple. I've got a Uri and I want to figure out which route it maps to so I can do some checks on the various pieces of the route: controller, action, etc. How do I go from Uri to RouteData or Route? ...

ASP.NET MVC - Get a URL to the current action that doesn't include the passed ID

I have an action in which I want to intercept any possible integer id that comes and place it behind a hash. (I have some Javascript that is handling the id). I am only doing this extra step for the sake of URL-hackers like me who might forget my convention of putting a hash before the id. Here is my action: public ActionResult Edit(in...

Is it OK to send a 301 redirect with an action filter?

I'm writing a new asp.net mvc application and I've been toying with the idea of allowing my user to post short, concise urls to content that he has posted. Those short url's will be handy in cramped spaces like Twitter and comment areas. I like this idea as I'm not a huge fan of url shorteners because they're so vague and you're never re...

Rewriting url after ajax call in a mvc application

Is there any way to change the url after an ajax call. I have a page (eg., url - xyz.com/employees) which displays all the employees, and there is a link on the page named 'Add Employee' which returns a partial view. As this being an ajax call, the url remains the same, is there anyway to change the url to xyz.com/addemployee after retur...

Exceptions in System.Web.Routing.RouteCollection.GetRouteData

I've been getting two exceptions at random times in my asp.net mvc code running on iis7: Exception type: InvalidOperationException Exception message: Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.List...

ASP.NET localhost routing issue

A call to localhost ( using the VS 2008 integrated webserver ) is not working ( empty page.. ) http://localhost:6666 but a call to a remote IIS http://asdf.com/MyApp is routed to the correct controler and method (SearchController -> Search )... MyApp is the IIS directory in which the folder "Controller" is... The routingcode: ...

How can I learn to stop worrying and love ASP.NET MVC Forms?

MVC encourages RESTful URL's, yet HTML forms by nature append the data in query string values. My action takes "text" as a string parameter. And my form is: <% using(Html.BeginForm("Action", "Controller")) { %> <%= Html.TextBox("text") %> <input type="submit" value="submit" /> <% } %> My action is: public ActionResult Action(stri...

ASP.NET w/ Restful Routes: Accessing a (sub)controller from within a resource

I'm not really sure how to express this, but one pattern I often see in RoR apps is something like this: /Post/postid/Comment/commentid or /Project/projectid/Tasks/taskid Essentially in the model since a Project has Tasks you can access the TaskController from within a project resource. Now I have started using the SimplyRestfulRout...

How to have generic routes in ASP.NET MVC, but handle unknown actions?

If I have a route: routes.MapRoute( "RouteName", // route name "{action}", // url with parameters new { controller = "Home", action = "Index", id = "" } // parameter defaults ); I want to be able to catch URL's of the form: http://site...

asp.net MVC RenderAction coordinator

We're looking at the ASP.NET MVC 2 beta RenderAction() method. We like it very much but it seems that we can't use async controllers with it. Does anyone have an example of a "controller" that can figure out all the actions that will be called, cache the data, then let the called actions know that their data already exists vs. having ...

Display 404 File Not Found View If Catch All Route Does Not Match

Hi All, I have a catch-all route setup in ASP.NET MVC, so I can capture /this-page, /that-page etc. When you hit a page the action is invoked, say Index(string page) and then page is tested against a value in the database to determine if the page can be found. If it can't be found, I want to display the view FileNotFound which is in ...

different ActionInvoker based on actions assigned in global.asax

how would i go about finding out what action was defined for this function protected override void ProcessRequest(HttpContextBase httpContext) { IController Controller = new CatalogController(); (Controller as Controller).ActionInvoker = new MyActionInvoker(); Controller.Execute(RequestContext); } a...

Can you pass a model with RedirectToAction?

I'm using mvc 2 release candidate, and am wondering if there's any way to pass a model to an action using RedirectToAction. For example, I have an edit action which takes an ID, and loads the record from a database, displays the current values in text boxes and lets the user edit and click submit: public ActionResult Edit(int ID) The...

changing view mvc 2 causes problems handing post

I have a controller with the following actions: public ActionResult Create() { return View(new MyModel()); } [HttpPost] public ActionResult Create(MyModel model) { //Update database ... //Pass the current model so we don't have to load it from the database return View("Details", model); } [HttpPost] public ActionRe...

MVC routing for parent child relationships

I'm building an APS.net MVC 2 app, where I have a parent table and a child table. I've got the controller, view and model built for the parent table, so I can Add, Edit, View Details and dete records from the parent table. I using the following routing to do this: routes.MapRoute( "Default", ...

MVC Post with dynamic routing.

I've created a routing structure whereas the action part of the URL serves as a dynamic handler for picking a specific user created system name. i.e. http://mysite.com/Systems/%5BSystemName%5D/Configure, where [SystemName] designates the name of the system they would like to configure. The method that routes the system is the following...

ASP.NET MVC: How to "understand" legacy URLs but not write them?

Please excuse the confusing title ;) We've built an ASP.NET MVC application to replace our "old" ASP.NET webforms monster. We still want to support some of the old URLs used there, because these may still float around in E-Mails etc. somewhere out there. For example: Our old system used the URL ~/Password.aspx, the URL in the new MVC s...