asp.net-mvc-routing

How to mask the controller and action name from the browser?

六月ゝ 毕业季﹏ 提交于 2019-12-12 02:46:31
问题 I want to display just the host url in the browser. Example: www.test.com/account/login or www.test.com/contact/index or www.test.com/order/details/12 to only display: www.test.com in browser 回答1: First of all in terms of usability and in terms of SEO, what is considered "good content" is something that your users can link to . If you build a "page" that has no URL path, then your users won't be able to link to it, share the link, etc. Search engines will also not be able to crawl it, so it

RedirectToAction As Get Request format

故事扮演 提交于 2019-12-12 02:14:31
问题 I have an action result that I want to redirect to an action with a dynamic ID. return RedirectToAction("Engine", new {id = latestVersion.Id}); However, the URL that returns ends up being: domain.com/project/engine/xxx what I need however is it to be: domain.com/project/engine?id=xxx Here are my current maproutes: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter

ASP.NET MVC 2 route errors - problems when using cottsak's solution

谁说我不能喝 提交于 2019-12-12 01:58:41
问题 I figured it'd be easier to ask here, where I can post some code, than in the comments of his solution. To see his solution, go here. EDIT: Some progress, but a new error. In my ErrorController class, I'm getting a NotImplementedException: public ActionResult InvokeHttp404(HttpContextBase httpContext) { IKernel kernal = new StandardKernel(); IController errorController = kernal.Get<ErrorController>(); var errorRoute = new RouteData(); errorRoute.Values.Add("controller", "Error"); errorRoute

asp.net MvcHandler.ProcessRequest is never called

不问归期 提交于 2019-12-12 01:54:55
问题 On Asp.Net MVC 3 I have overwritten the MvcRouteHandler and MvcHandler to include handling the subdomain part of the Url. However it never seems to call ProcessRequest method of MvcHandler. public class SubDomainMvcRouteHandler : MvcRouteHandler { protected override IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext) { return new SubDomainMvcHandler(requestContext); } } public class SubDomainMvcHandler : MvcHandler { public SubDomainMvcHandler(RequestContext context)

MVC Ignore Route

孤者浪人 提交于 2019-12-12 01:23:39
问题 how I create a Ignore route to a Virtual Directory inside my ASP.Net MVC website? my website is IT02:8069 and I create a virtual directory IT02:8069/AVR01 because inside of this directory I have files with this path IT02:8069/AVR01/2012/05/14/09/10/59000c00412.spx, but if I try connect in this path I get the erro 500.19. All files inside this path has are *.spx 回答1: updated: try this: routes.IgnoreRoute("AVR01/{*pathInfo}"); 来源: https://stackoverflow.com/questions/10637334/mvc-ignore-route

Html ActionLink Route problem

独自空忆成欢 提交于 2019-12-12 01:20:01
问题 i have defined the following Routes: routes.MapRoute("Blog", "Blog/{controller}/{action}", new { controller = "Test", action = "Index" }); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); When i call http://localhost/ all Links are wrong and go to the Blog: @Html.ActionLink("About", "About", "Home") creates the following URL: localhost/Blog/About but

After a change to the default routing map my actionlinks stopped working

我只是一个虾纸丫 提交于 2019-12-12 01:02:43
问题 I made a change to my routing map which is following now: routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}/{title}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, title = UrlParameter.Optional } ); And this is the actionlinks that are not working anymore: @Html.ActionLink("Category", "CategoryList", "Category") When I click on this actionlink nothing happens the url stays the same http://localhost:62394/ as the page reloads. its so weird

Get the VirtualPath From the Area, Controller and Action

浪子不回头ぞ 提交于 2019-12-11 23:22:37
问题 I was wondering how to get a URL given the area, controller and action names. So far all I have managed to come up with is: var httpContext = new HttpContextWrapper(HttpContext.Current); var routeData = RouteTable.Routes.GetRouteData(httpContext); if (routeData != null) { var virtualPath = routeData.Route.GetVirtualPath(new RequestContext(httpContext, routeData), new RouteValueDictionary(new { area = "Pages", controller = "Home", action = "Index" })); if (virtualPath != null) newNode.Url = "~

WebAPI2 and MVC5 route config

醉酒当歌 提交于 2019-12-11 19:47:41
问题 I have coded a C# ASP.net MVC5 internet application that works well and I can do CRUD operations using a Person model. I have added a WebAPI2 controller that uses the entity framework but am getting errors when trying to browse to any of the WebAPI controller methods. The WebAPI2 controller is called PersonAPIController . The Getpeople method has the // GET api/PersonAPI comment above the method, yet when browsing to this method, I am getting this error: The resource cannot be found. Is this

MVC3 Routing - Routes that builds on each other

ε祈祈猫儿з 提交于 2019-12-11 19:18:20
问题 I have an AREA setup in my project. I need to make the routes for the area progressive, meaning that the route will build on each other. I'm looking at this as something like a link list. Each node in the list will have a reference to a parent. As move from left to right in the list it builds, and from right to left it removes. In the area, I have companies and that have contacts, and child companies. For example, I have companies that would have the following: /Companies/list /Company/{Id}