asp.net-mvc-routing

IoC Castle Windsor in MVC routing problem

∥☆過路亽.° 提交于 2019-12-06 15:24:06
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 WindsorControllerFactory : DefaultControllerFactory { #region Constants and Fields /// <summary> /// The container. /// <

ASP.NET MVC 3 Case Sensitive URLs

十年热恋 提交于 2019-12-06 13:49:35
I am doing a bad thing here. I am asking a question without trying out first by hopping that someone knows an easy way of doing this. Any chance we can make ASP.NET MVC Routing system case sensitive? I would like the following two Urls to be different: example.com/a example.com/A Do we have an easy fix or should write our own handler for this. I haven't tried it, but I would think that if you use a regular expression route constraint that only matched the uppercase and lowercase seperate, that would work. I don't think it's a good idea though. That seems like a bad idea. You're assuming that

MVC 3 exception: The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc

a 夏天 提交于 2019-12-06 13:41:49
My application seems to run fine, but I keep getting these exceptions in log4net logs: The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Agency(Int32)' in 'COPSGMIS.Controllers.QuestionController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Not sure whats going wrong? My controller: public ActionResult Agency(int id) { QuestionDAL qd = new QuestionDAL(); var agency = qd.GetAgencyDetails(id); agency.Reviews = qd.GetAgencyReviews(id); return

UriPathExtensionMapping in MVC 4

二次信任 提交于 2019-12-06 13:35:21
问题 How do I use UriPathExtensionMapping in MVC4? I've added the mapping in the formatter such that: MediaTypeMappings.Add(new UriPathExtensionMapping("json", new MediaTypeHeaderValue("application/json")) But I can't use the extension on my route unless I add a verb, such as: routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}.{extension}" ); Then it'll recognize my desired media type, but it also starts expecting "extension" as a parameter on the action. Example: public

MVC 3 Routing and Action Links not following expected contextual Route

寵の児 提交于 2019-12-06 13:31:44
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 = "Space", action = "Index", id = UrlParameter.Optional }); Navigating to TEST/Space/Index works, as

ASP.NET MVC 4 Routing I just can't figure out

自作多情 提交于 2019-12-06 13:19:08
I'm working on a project in ASP.NET MVC 4 and I'm at a bit of a loss with a particular routing. I have a lot of custom routes already in the project. I am currently making a bunch of controllers for the frontend of the site (publicly visible part) to be able to do thing like abc.com/OurSeoFeatures that gets routed to /OurSeoFeatures/Index Is there any way to do this so that the above would route to something like /frontend/OurSeoFeature and another page would route to /frontend/anotherpage and also still have my other routes correctly? It seems to me that the above would hit the default route

ASP.NET Mvc - nullable parameters and comma as separator

别来无恙 提交于 2019-12-06 12:48:52
How should I define route in my global.asax to be able use nullable parameters and coma as separator? I'm trying to implement routing rule for my search users page like "{Controller}/{Action},{name},{page},{status}" Full entry from the Global.asax: routes.MapRoute( "Search", "{controller}/{action},{name},{page},{status}", new { controller = "User", action = "Find", name = UrlParameter.Optional, page = UrlParameter.Optional, status = UrlParameter.Optional } ); Routine defined like above works fine when I'm entering all parameters, but when some parameters are equal to null routing fails (for

Hide Querystring in MVC action

心已入冬 提交于 2019-12-06 12:10:16
I want to hide the Querystring into My controller's action. In my application scenariois something like this: 1) I have opened new action into new Window as: var check="Particular String" var url = rootUrl("Home/Preview?Docs=" + check); window.open(url, '_blank'); 2) On controller's Side I have used some code into Controller's action as: public ActionResult Preview(string Docs) { TempData["Docs"] = Docs; return RedirectToAction("UnInvoicedPreview"); } My Query:: 1) when opening new window it shows the Query string in the Begining(uptill when it doesn't redirects to another action). 2) I dont

Pass List<int> from actionlink to controller method

可紊 提交于 2019-12-06 11:11:08
问题 In my controller I have this: ViewBag.lstIWantToSend= lstApps.Select(x => x.ID).ToList(); // creates a List<int> and is being populated correctly I want to pass that list to another controller.. so in my view I have: @Html.ActionLink(count, "ActionName", new { lstApps = ViewBag.lstIWantToSend }, null) Method in Controller: public ActionResult ActionName(List<int> lstApps) // lstApps is always null Is there a way to send a list of ints as a route value to a controller method? 回答1: its not

Route patterns vs individual routes

谁说我不能喝 提交于 2019-12-06 09:48:54
Currently I have a controller which looks something like this: public class MyController : Controller { public ActionResult Action1 (int id1, int id2) { } public ActionResult Action2 (int id3, int id4) { } } As you can see both my controllers have the same parameter "pattern", two non-nullable signed integers. My route config looks like this: routes.MapRoute( name: "Action2", url: "My/Action2/{id3}-{id4}", defaults: new { controller = "My", action = "Action2", id3 = 0, id4 = 0 } ); routes.MapRoute( name: "Action1", url: "My/Action1/{id1}-{id2}", defaults: new { controller = "My", action =