asp.net-mvc-routing

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

杀马特。学长 韩版系。学妹 提交于 2019-12-17 07:34:27
问题 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 controller has a number of actions and I'd like to use URL's like the following: http://example.com -> calls Index() http://example.com/showdevice/1234 -> calls ShowDevice

ASP.NET MVC Routing - add .html extension to routes

孤街醉人 提交于 2019-12-17 07:30:25
问题 i am pretty new to MVC and Routing and i was asked to modify an app to use diffrent url's. a task that is a bit over me since i have no experience. ok, lets talk a bit of code: routes.MapRoute( "CategoryBySeName", // Route name "products/{SeName}", // URL with parameters new { controller = "Catalog", action = "CategoryBySeName" } ); this works as expected, but then the client wanted ".html" at the end of paths, so i changed: "products/{SeName}", // URL with parameters to: "products/{SeName}

How does a method in MVC WebApi map to an http verb?

痞子三分冷 提交于 2019-12-17 04:22:53
问题 In the 5-minute video at the following link, at the 1:10 mark, Jon Galloway says that adding a method called DeleteComment to his CommentsController controller class will by convention map automatically to the delete http verb. How does MVC with WebApi know how to rout the methods to the right verbs? I know the routing in the global.asax.cs file routes requests to the correct controller, but how does a delete request get "mapped by convention" to the delete method, or any method? Especially

How does a method in MVC WebApi map to an http verb?

强颜欢笑 提交于 2019-12-17 04:22:11
问题 In the 5-minute video at the following link, at the 1:10 mark, Jon Galloway says that adding a method called DeleteComment to his CommentsController controller class will by convention map automatically to the delete http verb. How does MVC with WebApi know how to rout the methods to the right verbs? I know the routing in the global.asax.cs file routes requests to the correct controller, but how does a delete request get "mapped by convention" to the delete method, or any method? Especially

URLs with slash in parameter?

北慕城南 提交于 2019-12-17 03:07:33
问题 Question: I am creating a wiki software, basically a clone of wikipedia/mediawiki, but in ASP.NET MVC (the MVC is the point, so don't recommend me ScrewTurn). Now I have a question: I use this route mapping, to route a URL like: http://en.wikipedia.org/wiki/ASP.NET routes.MapRoute( "Wiki", // Routenname //"{controller}/{action}/{id}", // URL mit Parametern "wiki/{id}", // URL mit Parametern new { controller = "Wiki", action = "dbLookup", id = UrlParameter.Optional } // Parameterstandardwerte

Is it possible to get the controller and the action (NOT THEIR NAME!!) based on the url?

ぐ巨炮叔叔 提交于 2019-12-14 04:00:09
问题 I have found a dozens of threads about getting the name of the controller and method based on the url, I managed that just as well. Can I get the MethodInfo of the method based on their name automatically from the MVC engine, or do I have to do Type.GetType("Namespace.Controllers."+cname+"Controller").GetMethod(mname) ? Which is not so nice, since how do I know the namespace in a framework class? How do I know if the default naming patterns are being observed, or is there a different config

Using Both of Attribute and Convention Routing

て烟熏妆下的殇ゞ 提交于 2019-12-14 03:56:40
问题 Is there a way to use Convention and Attribute Routing together? I want to call an action method with the real name of method and controller when I defined the attribute routing. The mapping method is calling at startup: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes();/// routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id =

When does HttpRequest get created?

 ̄綄美尐妖づ 提交于 2019-12-14 03:54:35
问题 In my MVC web application, I'm checking Request.IsLocal to see if the application is running on my machine--if it is, I set a Global static variable which tells the rest of my application that I am in 'Debug Mode'. The problem is, I don't know when to do this check. I tried to do it in the global.asax.cs file, under Application_Start(), like this: protected void Application_Start() { if (Request.IsLocal) isDebug = true; AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes);

RouteAttribute broke my Default route

旧城冷巷雨未停 提交于 2019-12-14 03:35:04
问题 If I apply [Route(Name = "WhatEver")] to action, which I use as Default site route, I get HTTP 404 when accesing site root. For example: Create new sample MVC project. Add attributes routing: // file: App_Start/RouteConfig.cs public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); // Add this line routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new {

MVC 4 DomainRoute to Area uses wrong instance from RouteTable

左心房为你撑大大i 提交于 2019-12-14 02:43:48
问题 I have an ASP.NET MVC 4 app where I have two areas: Backstage Signup I have a class called DomainRoute that makes it possible to route an entire subdomain to an area: using System; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Web.Mvc; using System.Web.Routing; namespace Admin.Web.PresentationLogic { /// <summary> /// DomainRoute is an extension of the default Route, that makes it possible to route domains and subdomains the specific controllers. /// <