asp.net-mvc-routing

ASP.NET MVC Dynamic Routes and Action Links with Arbitrary Depth [duplicate]

ぐ巨炮叔叔 提交于 2019-11-30 10:15:15
This question already has an answer here: asp.net mvc complex routing for tree path 4 answers I'd like to put together a forum/message board with ASP.NET MVC. Pretty common on these types of forums are hierarchical board categories, so for instance: -General Discussion -Technical Support --Website Technical support --Product Technical Support ---Product A Technical Support ---Product B Technical Support Below each category are then topics and messages belong to those topics. What I'm primarily concerned with is 1.) getting to the correct place, given a URL, 2.) not including boatloads of

Using IIS Application Request Routing (ARR) for ASP.NET MVC

让人想犯罪 __ 提交于 2019-11-30 09:06:20
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 requests 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.aspx My rule is just a bit different it is /shop(.*). Only requests that contain shop are send to a different server. I have to use rewrite, not redirect (The same as in the Picture) This works

ASP.NET MVC 3: RouteExistingFiles = true seems to have no effect

孤人 提交于 2019-11-30 08:54:47
I'm trying to understand how RouteExistingFiles works. So I've created a new MVC 3 internet project (MVC 4 behaves the same way) and put a HTMLPage.html file to the Content folder of my project. Now I went to the Global.Asax file and edited the RegisterRoutes function so it looks like this: public static void RegisterRoutes(RouteCollection routes) { routes.RouteExistingFiles = true; //Look for routes before looking if a static file exists routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new {controller = "Home", action = "Index", id = UrlParameter

angularjs with cshtml page only not html pages with web api 2

半世苍凉 提交于 2019-11-30 08:43:01
问题 I'm having asp. net mvc4 project. Angularjs is integrated. I have already built HTML pages and WEB APIs 2 as per previous requirements. Now for some reason i have to go with CSHTML pages. previously I had only web api project template so i couldnt go with cshtml pages as ONLY MVC controller can return partial page(cshtml) but i was using only web apis... So changed whole project template and so now i can have mvc controllers... ... In short, currently I have mvc4 project with already built

MVC MapPageRoute and ActionLink

我们两清 提交于 2019-11-30 08:20:19
问题 I have created a page route so I can integrate my MVC application with a few WebForms pages that exist in my project: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // register the report routes routes.MapPageRoute("ReportTest", "reports/test", "~/WebForms/Test.aspx" ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter

Why CSS and JS files bypass Asp.Net MVC routes?

纵饮孤独 提交于 2019-11-30 05:55:39
I received a prototype application built with Asp.Net MVC4. It is currently replacing the default controller factory with a custom one using NInject, ServiceLocator and all. The problem is that by replacing the default controller factory, the requests to JS files are being treated as if it was a legit request for a controller and an action. So, looking at the default template create by Visual Studio, route configuration looks like this: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "

ASP.NET Web API get child list (hierarchical resources)

馋奶兔 提交于 2019-11-30 05:24:10
问题 I have the following rest schema that I'd like to implement using the ASP.NET Web Api: http://mydomain/api/students http://mydomain/api/students/s123 http://mydomain/api/students/s123/classes http://mydomain/api/students/s123/classes/c456 I've got the first two links working properly using the ApiController and the following two methods: public class StudentsController : ApiController { // GET api/students public IEnumerable<Student> GetStudents() { } // GET api/students/5 public IEnumerable

Lower case URLs in ASP.NET MVC

≡放荡痞女 提交于 2019-11-30 05:15:31
Is it possible to force/extend the routing engine to generate URLs in lower case, giving /controller/action instead of /Controller/Action ? What's more, you should force any incoming requests that are uppercase to be redirected to the lowercase version. Search engines treat URLs case-sensitively, meaning that if you have multiple links to the same content, that content's page ranking is distributed and hence diluted. Returning HTTP 301 (Moved Permanently) for such links will cause search engines to 'merge' these links and hence only hold one reference to your content. Add something like this

How to ignore current route values when generating links?

梦想的初衷 提交于 2019-11-30 05:07:06
The question is similar to asp.net mvc Html.ActionLink() keeping route value I don't want , but with a twist that makes it more complex. Starting from a default new MVC3 app, I change the routes to: routes.MapRoute( "r1", // Route name "{controller}/{id}/{action}" ); routes.MapRoute( "r2", // Route name "{controller}/{action}" ); Notice that the id comes before the action in the first. Then in Home\Index.cshtml, I add: @Url.Action("Index") @Url.Action("Index", new { id = "blah" }) @Url.Action("Index", new { id = "" }) Now I navigate to /Home/Foo/Index and look at the 3 generated links. I get "

Set index.html as the default page

一世执手 提交于 2019-11-30 04:24:31
I have an empty ASP.NET application and I added an index.html file. I want to set the index.html as default page for the site. I have tried to right click on the index.html and set as start page, and when I run it the url is: http://localhost:5134/index.html but what I really want is that when I type: http://localhost:5134 , it should load the index.html page. my route config: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new