problem about asp.net-mvc-routing-Collection of common programming errors


  • Ryan Sampson
    asp.net-mvc asp.net-mvc-routing
    I have custom error pages setup using<customErrors mode=”On” defaultRedirect=”~/Home/Error”><error statusCode=”404″ redirect=”~/Home/PageNotFound” /></customErrors>I created a page that throws and exception and I get redirected to the correct error pages.However I am noticing these errors in elmah on the production webserver: System.InvalidOperationException The view ‘Error’ or its master was not found or no view engine supports the searched locations. The following locations w

  • Display
    asp.net-mvc-4 asp.net-mvc-routing
    I tried to write custom routes.Always i have 404 error what is wrong.I read about routing and did not figure out. I want to display contents like below codes and name must be between a-Z and 0-9.Thanks.{action}/{name} /details/kll219dklroutes.MapRoute(name: “Default”,url: “{controller}/{action}/{id}”,defaults: new { controller = “home”, action = “index”, id = UrlParameter.Optional });routes.MapRoute(name: “test”,url: “details/{name}”,defaults: new { controller = “Test”, action = “Details”, name

  • Valamas – AUS
    mvc asp.net-mvc-3 asp.net-mvc-routing
    I am using a third party nuget called AttributeRouting which registeres routes using attributes. I have a unique situation and i need to remove a route from the route table on Application_Start or similar. How can this be done?I have supplied a screenshot of the route i want to remove. I have even named it “RemoveMePlease”.thanks

  • A.R.
    c# asp.net-mvc-4 asp.net-mvc-routing
    Is there a way to get MVC4 to call different actions based on a GET variable in the URL?For example, let’s say I have the following two actions.[HttpPost] public ActionResult SubmitCrash(CrashReport rawData) {return View(); }[HttpPost] public ActionResult SubmitBug(BugReport data) {return View(); }Is there a way I can use the following URLs to have MVC4 ‘choose’ which action to call?http://MySite/Submit?Crash (calls ‘SubmitCrash’) http://MySite/Submit?Bug (calls ‘SubmitBug’)UPDATE: I am very m

  • Maritim
    asp.net-mvc-4 iis-7.5 asp.net-mvc-routing
    I’m using routing in my ASP.NET MVC 4 application and I’m experiencing a very strange problem. I am attempting to establish a route to an area named Ekstranett, but if I use Ekstranett as the first URL parameter I get an Internal Server Error. I can use any word except for Ekstranett and I find that very strange. This is my setup:context.MapRoute(“Exception”,”Ekstranett/Exception/{action}/{*handle}”,new { controller = “Exception”, action = “General”, handle = UrlParameter.Optional },new[] { “MyP

  • Malcolm Frexner
    asp.net-mvc iis7 asp.net-mvc-routing
    I use a simple ASP.NET MVC web (the template you use when you create a new site) and the web works as expected in my live environment.I now try to use IIS Application Request Routing version 2. I have a rule that send all reuqests to a different server that match a rule.The settings are a bit like this: http://blogs.iis.net/wonyoo/archive/2008/07/09/application-request-routing-arr-as-a-reverse-proxy.aspxMy rule is just a bit different it is /shop(.*). Only requests that contain shop are send to

  • teresko
    asp.net-mvc asp.net-mvc-routing
    I’ve searched the internet high and low and checked all previously answered questions with the same title and I cannot figure this one out. I return RedirectToAction(“Index”, “Home”) from the action method in my authentication controller and then receive the following exception:Server Error in ‘/’ Application. The controller for path ‘/Home’ was not found or does not implement IController. Description: An unhandled exception occurred during the execution of the current web request. Please revie

  • teresko
    asp.net-mvc asp.net-mvc-routing
    I have currently the following routes:routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);routes.IgnoreRoute(“{resource}.gif/{*pathInfo}”);MvcRoute.MappUrl(“{controller}/{action}/{ID}”).WithDefaults(new { controller = “home”, action = “index”, ID = 0 }).WithConstraints(new { controller = “…” }).AddWithName(“default”, routes).RouteHandler = new MvcRouteHandler();MvcRoute.MappUrl(“{title}/{ID}”).WithDefaults(new { controller = “special”, action = “Index” }).AddWithName(“view”, routes).RouteHandler

  • teresko
    c# asp.net-mvc asp.net-mvc-3 asp.net-mvc-routing
    I want to catch the latest unhandled error application and redirect it to error page whenever error has occurred. But I got error “No matching route found for RedirectToRoute.” What’s the problem with my code? Here’s my implementation:Global.asaxroutes.MapRoute(“ErrorHandler”,”{ErrorHandler}/{action}/{errMsg}”,new {controller=”ErrorHandler”, action = “Index”, errMsg = UrlParameter.Optional });Application_Endprotected void Application_Error(object sender, EventArgs e){var strError = Server.GetLas

  • ataravati
    asp.net-mvc asp.net-mvc-routing
    I have the following controller:public class HomeController : Controller {public ActionResult Index(){return View();} }And, route:routes.MapRoute(“spa”,”{section}/{id}”,new { controller = “Home”, action = “Index”, id = UrlParameter.Optional },new { section = @”home|questions|admin” });When I use the following, I get an error message:return RedirectToAction(“Index”, “Home”);Error message:Server Error in ‘/’ Application.No route in the route table matches the supplied values. Description: An unhan

  • teresko
    asp.net-mvc asp.net-mvc-routing redirecttoaction redirecttoroute
    Im Redirecting my action Using RedirectToRoute with parametes and i defined the route in global.asaxreturn RedirectToRoute(“RouteName”, new { action = “Search”, Id, Customer, Source,class,Type,Desc, Date, Loc, input, prod, effDate, remainDate });routes.MapRoute(name: “RouteName”,url: “{controller}/{action}/{Id}/{Customer}/{Source}/{class}/{Type}/{Desc}/{Date}/{Loc}/{input}/{prod}/{effdate}/{remainDate}/”,defaults: new{controller = “MyCOntroller”,action = “Search”,Id = UrlParameter.Optional,Custo

  • David Williams
    asp.net-mvc asp.net-mvc-3 asp.net-mvc-routing
    Given the controller belowpublic class MyController : Controller {public ActionResult Index(){return View();}public ActionResult Test(){return RedirectToRoute(new { action = “Index” });}}And this routingpublic static void RegisterRoutes(RouteCollection routes) {routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);routes.MapRoute(“Route1″,”Route1”,new {controller = “Account”, action = “Index”});routes.MapRoute(“Default”, // Route name”{controller}/{action}/{id}”, // URL with parametersnew { controlle

  • Ufuk Haciogullari
    asp.net-mvc asp.net-mvc-routing
    I need to ignore routes matching this schema/{controller}/edit/undefined{controller} – could be any controllerBTW I was wondering when to use Ignore and when IgnoreRoute.

  • Leniel Macaferi
    asp.net asp.net-mvc asp.net-mvc-3 error-handling asp.net-mvc-routing
    I want to return a HTTP status 404 if invalid arguments are passed to my controller. For example if I have a controller that looks like:public ActionResult GetAccount(int id) {… }Then I want to return a 404 if say urls such as these are encountered:/GetAccount /GetAccount/notanumberi.e. I want to trap the ArgumentException that is thrown.I know I could use a nullable type:public ActionResult GetAccount(int? id) {if(id == null) throw new HttpException(404, “Not found”); }But that’s pretty icky