asp.net-mvc-routing

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

廉价感情. 提交于 2019-12-08 02:30:48
问题 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 really sure what you're going to get. Instead of using a url shortener I want to give my client the ability to post: http://domain.com/p/234 which does a 301

MVC 3 Routing and Action Links not following expected contextual Route

我与影子孤独终老i 提交于 2019-12-08 02:05:53
问题 I'm attempting to do a custom route so I can prefix a url in my application with a chosen string and the do some processing based on that. The problem I'm running into is, that the action links that are generated are not contextualized based on the url that it exists on. Routes: routes.MapRoute( "TestRoute", "TEST/{controller}/{action}/{id}", new { controller = "Space", action = "Index", id = UrlParameter.Optional }); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller

How does routing for ASP.NET Web Pages work without global.asax

蓝咒 提交于 2019-12-07 23:01:34
问题 Web server with ASP.Net 4.0 installed, Web Pages 2.0 DLLs bin deployed. Pages written in cshtml/razor, but routing is not working. What is required on the server to activate routing when using only Web Pages as opposed to full MVC (where I'd have my routes defined in global.asax)? Right now I can only call my pages using the traditional URL and query string. Any pointers appreciated. 回答1: There are two kinds of "routing" available in the Web Pages framework. The default routing works on

Fallback route for MVC Areas

假如想象 提交于 2019-12-07 21:47:07
问题 Using asp.net core MVC application here. I have my areas defined and routing works as expected. One thing i would like to do, is have a fallback route in case the area does not exist. I have the following structure: APP -- Areas -- SharedArea -- Controllers -- LoginController -- UserController -- AnotherController -- AndSoOnController -- SomeArea1 -- Controllers -- HomeController -- SomeArea2 -- Controllers -- HomeController -- LoginController My ultimate goal, is to have shared controllers

IoC Castle Windsor in MVC routing problem

冷暖自知 提交于 2019-12-07 18:48:18
问题 I've set up castle windsor in my mvc app. everything works great except it also catches routes that are of type link or image. The problem is that right before exiting from the controller and generating the view "GetControllerInstance" is executed with 'null' type. This happends anytime there a link on a page like: <link rel="stylesheet" type="text/css" href="non-existing.css"/> Or a link to an image that does not exist. Why is this happening? My windows class: public class

asp.net mvc routing question

烈酒焚心 提交于 2019-12-07 18:35:34
问题 the default routing works fine mysite.com/home/about and i even see how to customize it to make it shorter so i can say: mysite.com/edit/1 instead of mysite.com/home/edit/1 but how can i make it longer to handle url like the following mysite.com/admin/user/1 // works mysite.com/admin/user/details // does not work mysite.com/admin/question/create // does not work i cant just treat the id as an action? i need a custom route? do i need to create new controllers for each table or can i route them

Render bootstrap dropdown menu with in c# MVC3 Html.ActionLink

不想你离开。 提交于 2019-12-07 16:52:00
问题 Therefore I faced an issue with MVC ActionLink and bootstrap dropdown. I succeeded with simple menu extension where I passed such a parameters like strings and one bool. But now I am trying to make my own extension which could generate Bootstrap Dropdown and add selected css class to parent of the dropdown - "ONEofTHEdropdownITEMSselected" - when one of those items in dropdown is selected (when selecting dropdown item it routes to different controller there fore can be few or more controllers

AttributeRouting - Correct way of Getting the Action Name from RouteData

白昼怎懂夜的黑 提交于 2019-12-07 16:45:34
问题 I have recently started using attribute routing for my action methods and am struggling in getting the action name (and/or id) from the RouteData. Below is an example of how I use the attrubues like so: [Route( "Edit/{id:int}" )] public ActionResult Edit( int id ) { ... } Previously I used the following method as an extension of RouteData to retrieve the value public static string GetActionName( this RouteData routeData ) { return routeData.Values[ "Action" ] as string; } This used to return

Multiple levels in MVC custom routing

旧街凉风 提交于 2019-12-07 15:50:31
I am trying to build my own little cms. I created an abstract pageBase class that is inherited by Static, Reviews, Articles, News. Each having there own controller methods. My problem is that I need to allow the admin to define his own custom path levels. E.g. news\local\mynewdog or Articles\events\conventions\mycon . So I would like a way to pass an array of strings and also set the custom routing. You can make CMS-style routes seamlessly with a custom RouteBase subclass. public class PageInfo { // VirtualPath should not have a leading slash // example: events/conventions/mycon public string

Getting area, controller and action names inside filter attributes

别说谁变了你拦得住时间么 提交于 2019-12-07 15:24:38
问题 I have global attribute in which i need to know the area, controller and action. I can't use RawUrl due to routes (inside area registration and attribute routing). I have followed the following two approaches but in both cases, my area is coming back as null. When i use a route then i get the area name just fine. Why is my area null when i do redirecttoaction or url.action or type the url manually etc? We are using MVC 5.0. 1: var routingValues = RouteTable.Routes.GetRouteData(new