asp.net-mvc-routing

Language-specific Default URL using MVC's Attribute Routing and RouteLocalization.mvc

半腔热情 提交于 2019-12-04 10:12:31
I would like to be able to create a succinct language-specific default URL for my website so that when someone browses to: somesite.com They get redirected to a language-culture page such as: somesite.com/en-US/ somesite.com/sp-MX/ somesite.com/fr-FR/ Specifically, I do not want /Home/Index appended to the URLs: somesite.com/en-US/Home/Index somesite.com/sp-MX/Home/Index somesite.com/fr-FR/Home/Index I am committed to making this site using RouteLocalization.mvc Dresel/RouteLocalization Translating Your ASP.NET MVC Routes And I would like to use MVC Attribute Routing to the extent feasible. I

Routing in Web Api in ASP.NET MVC 4

佐手、 提交于 2019-12-04 09:34:22
问题 I am using web api with ASP.NET MVC 4. I have the following named controller CustomerController : Controller CustomerApiController : ApiController Earlier my CustomerApiController was named CustomersController so to access it, I simply had to punch in the following url localhost/api/Customers but now I have to keep the api controller name as CustomerApiController . I want to be able to hit the same method using localhost/api/Customers what changes do I have to make ? I have tried making some

Is it possible to use different layouts in MVC4 based off of routes?

佐手、 提交于 2019-12-04 08:57:29
问题 I have a separate section (route) of my website that I would like to use a different layout/css etc. So when users at the main section of my website they get the default layout. But when they log in and go to the store, the store section (route) uses a different layout/css. So... www.blahblahblah.com/ www.blahblahblah.com/admin/ www.blahblahblah.com/home/contactus/ ...all use the default _Layout BUT... www.blahblahblah.com/store/ www.blahblahblah.com/store/admin/ ...use _LayoutStore I've seen

ASP.NET MVC4 with webforms Default.aspx as the start page

醉酒当歌 提交于 2019-12-04 08:34:42
I had an ASP.NET MVC4 app with the following routing defined in the Global.asax.cs. The app's start page is Index.cshtml view that is returned from the action method Index() of the Home controller. I then added a legacy ASP.NET WebForms app that had Default.aspx as the start page. How can I make this Default.aspx page as the start page of this integrated MVC+WebForms app: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}.mvc/{action}/{id}", new { action = "Index", id = "" } ); routes.MapRoute(

Can Areas in an ASP.NET MVC 2 application map to a subdomain?

烂漫一生 提交于 2019-12-04 08:20:46
问题 Is there a way to map the Areas within an ASP.NET MVC 2 application to subdomains such as movies.example.com/Theater/View/2 instead of example.com/Movies/Theater/View/2 where { area = "Movies", controller = "Theater", action = "View", id = 2 }. 回答1: Areas are not directly related to routing, so your question becomes "does routing support subdomains?" The answer to that is unfortunately that there is no built-in support for this. However, the good news is that many people have tried and found

Routing legacy requests with and without querystring

南楼画角 提交于 2019-12-04 07:33:12
(Before starting: I am aware of this and this . I'd like to find a more concise solution -if possible- for a slightly more specific problem) I'm rewriting an old Webforms app in MVC. As usual, no permalinks should be broken. I'm using standard {controller}/{action}/{id} routes. Legacy paths are usually SomePage.aspx?ID=xxx , and I have one particular case where Foo.aspx is a list of Bar (new URL: /Bar or /Bar/Index ) and Foo.aspx?ID=xxx is the Bar detail (new URL: /Bar/View/xxx ) One possible workaround is adding the following before the Default MapRoute : routes.MapRoute("Bar View", "Foo.aspx

Issue when trying to route a path that ends with a '.'

99封情书 提交于 2019-12-04 05:56:03
问题 I'm trying to route a path like this: http://www.wikipediamaze.com/wiki/Washington,_D.C. The routing framework is not picking this up as a valid route and giving me a "Cannot find resource" error. Anyone know how I can get around this? It's not even getting to my controller factory so it's as if it doesn't even recognize it as a route or perhaps looking for an actual file. I don't have any problems with similar routes like this: http://www.wikipediamaze.com/wiki/United_States http://www

With asp.net MVC4, how can I make my root index.html be executed by default?

给你一囗甜甜゛ 提交于 2019-12-04 05:48:44
For much of my web site, I want normal routing to occur the MVC way. However, when the app first launches, I don't want the route to go to /Home/Index.cshtml. I want it to go to simply /Index.html My current RegisterRoutes looks like this (and does not achieve my goal) public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("index.html"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } public ActionResult Index()

Domain dependent routing ASP MVC 3

ぐ巨炮叔叔 提交于 2019-12-04 05:04:36
问题 I have two domains: mydomain.com and mydomain.fr They both correspond to the same IP address. I want users typing mydomain.com to view page A (Controller = "Application" Action = "A" ) and users typing mydomain.fr to view page B (Controller = "ApplicationFR" Action = "B" ) I am using ASP.NET MVC 3 and the default route is mapped to page A. How can I achieve this ? EDIT: I tried to use the example provided but it seems not to work. Is it the right way to register the custom route ? public

MVC Routing without controller in the url

末鹿安然 提交于 2019-12-04 04:51:02
How do I configure ASP.NET MVC 3 routing so it doesn’t shown the controller in the url? Here's my routes routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.MapRoute( "HomeActions", "{action}", new { action= "AboutUs" } ); I need url: mysite.com/AboutUs But I have mysite.com/Home/AboutUs NerdFury I would be very specific about the url that you want to route. And place it above the default route. routes.MapRoute( "HomeActions", "AboutUs", new { controller = "Home", action= "AboutUs" } ); routes.MapRoute(