asp.net-mvc-routing

MVC 6 Routing, SPA fallback + 404 Error Page

随声附和 提交于 2019-12-30 04:38:04
问题 With RC1 of ASP.NET Core 1.0's MVC 6 you can map routes from within your Startup.Configure function when invoking app.UseMvc . I have mapped a "spa-fallback" route that will ensure that the HomeController and Index view are the defaults like so: public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { // ... omitted for brevity app.UseExceptionHandler("/Home/Error"); app.UseStatusCodePagesWithRedirects("/Home/Error/{0}"); app.UseMvc(routes => {

Getting error 404 not found with ASP.NET MVC Area routing

扶醉桌前 提交于 2019-12-30 04:31:27
问题 I am having a problem with an Area route in MVC 5. When I browse to /Evernote/EvernoteAuth I get a 404 resource cannot be found error. My area looks like this: Areas Evernote Controllers EvernoteAuthController Views EvernoteAuth Index.cshtml The EvernoteAreaRegistration.cs (UPDATE: RegisterArea() wasn't being called so I did a Clean and Rebuild. Now it is called but same result.) contains this route map: public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute(

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

馋奶兔 提交于 2019-12-30 03:12:10
问题 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

need help canonicalizing an HTTP GET form in asp.net mvc

佐手、 提交于 2019-12-29 09:37:11
问题 I have a form in an asp.net mvc site that serves 3 purposes: paging, sorting, and searching. These items should all be rendered in the same form, since returning the correct search results depends on variables from all 3 aspects. What I'm trying to do is move the parameters out of the querystring and put them in a canonical URL. I'm almost there, here are my 3 route configurations so far (using T4MVC for area, controller, and action names): context.MapRoute(null, "my-area/my-widgets/search/

MVC Custom Routing Subdomain

狂风中的少年 提交于 2019-12-29 09:12:18
问题 I'm trying to build a "Tenant" Subdomain route that attaches to a MVC Area. In this case I have an Area called "Tenant" which has two controllers; Public and Admin. My custom Route is used to grab the Subdomain if it matches then route them to the proper Controller-Action-Area. The base of this project came from the following http://www.matrichard.com/post/asp.net-mvc-5-routing-with-subdomain The problem I'm having is in the custom Subdomain Route. When I hit the Public/Index Route, the

MVC Custom Routing Subdomain

ε祈祈猫儿з 提交于 2019-12-29 09:12:14
问题 I'm trying to build a "Tenant" Subdomain route that attaches to a MVC Area. In this case I have an Area called "Tenant" which has two controllers; Public and Admin. My custom Route is used to grab the Subdomain if it matches then route them to the proper Controller-Action-Area. The base of this project came from the following http://www.matrichard.com/post/asp.net-mvc-5-routing-with-subdomain The problem I'm having is in the custom Subdomain Route. When I hit the Public/Index Route, the

Can anyone recreate the following bug I'm experiencing in routes with 2 or more optional parameters, in .NET 4.0 / MVC3?

三世轮回 提交于 2019-12-29 07:44:05
问题 I know that if you think you found a bug in the .NET framework you are most likely wrong, but that's why I'm writing this question, so please hear me out. I am fairly certain that there is a difference between the routes in .NET 3.5 and .NET 4.0 when it comes to optional parameters. Specifically if you have more than one optional parameter in your route. I have not been able to find this breaking change noted in any release notes of either .NET 4.0 or MVC 3 so thats why I call it a bug. EDIT:

Dynamic routing action name in ASP.NET MVC

早过忘川 提交于 2019-12-29 07:18:07
问题 I would like to create a dynamic routing to a URL like following: http://localhost:51577/Item/AnyActionName/Id Please note that the controller name is static and doesn't need to be dynamic. On the other hand, I need to have the action name part dynamic so that whatever is written in that part of URL, I would redirect the user to the Index action inside of Item controller. What I have tried so far is: public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute( "Items", "Item/

ASP.NET MVC 4 Web API fails to map path containing the string “con”?

北城余情 提交于 2019-12-29 06:47:14
问题 What is so wrong about the string "con"? OK, my api route configuration is rather uninteresting: config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); The LocationController has the following method: public List<LocationViewModel> Get(string id) { return _ds.SearchLocations(id); } Everything works as it should, except that I am getting an HTTP 404 error when I try to get the resource like this: /api/location

Dynamically modify RouteValueDictionary

泪湿孤枕 提交于 2019-12-28 18:29:09
问题 As a followup of this question, I'm trying to implement a custom route constraint in order to dynamically modify the RouteValueDictionary for a specific route. I'm 95% of the way there: I can match any route based on the supplied parameter pattern matching the action specified in the url. The very last step of this process is to overwrite the RouteValueDictionary to rename the keys as the appropriate parameters for the controller action. Here's the relevant snippet of my code (the entire