asp.net-routing

Multiple RoutePrefixes per controller using MVC Attribute routing?

匆匆过客 提交于 2019-11-30 14:41:37
With the new MVC Attribute routing, I know you can assign multiple Route attributes to a single ActionResult , but I am looking for a way to do the same at the RoutePrefix level. I have a controller which, in every action, should be accessible by three routes: /Games/{Title}/Characters/{Route} /Books/{Title}/Characters/{Route} /Cinema/{Title}/Characters/{Route} I tried putting three individual RoutePrefix attributes, but I get the error Deuplace RoutePrefix attribute . If I try to use a comma-separated list, I get Best override method for does not contain a constructor that takes 3 arguments .

ASP.NET routing on IIS 6

老子叫甜甜 提交于 2019-11-30 06:29:22
I have created a basic site using ASP.NET routing according to Mike Ormond's example "Using ASP.NET routing Independent of MVC". This works fine on my local machine running the built-in web server. However, when I deploy it to my server ( Windows Server 2003 , IIS 6, ASP.NET 3.5 SP1) it just shows a 404 error. I have read somewhere that I am meant to set up wildcard routing. How can I do this? What other configuration changes needs to be done to make it work on my server? Johnno Nolan You will find some good information on Steve Sanderson’s blog post " Deploying ASP.NET MVC to IIS 6 ." Chris

ASP.Net Mvc 3 Url.Action method uses parameter values from previous request

别等时光非礼了梦想. 提交于 2019-11-30 03:09:10
问题 When Urls are autogenerated using the Url.Action helper, if a page contains a line similar to @Url.Action("Edit","Student") is expected to generate a url like domain/student/edit and its working as expected. But if the requested url contains some parameters, like domain/student/edit/210 , the above code uses these parameters from the previous request and generates something similar even though I've not provided any such parameter to the Action method. In short, if the requested url contains

Multiple RoutePrefixes per controller using MVC Attribute routing?

[亡魂溺海] 提交于 2019-11-29 20:07:52
问题 With the new MVC Attribute routing, I know you can assign multiple Route attributes to a single ActionResult , but I am looking for a way to do the same at the RoutePrefix level. I have a controller which, in every action, should be accessible by three routes: /Games/{Title}/Characters/{Route} /Books/{Title}/Characters/{Route} /Cinema/{Title}/Characters/{Route} I tried putting three individual RoutePrefix attributes, but I get the error Deuplace RoutePrefix attribute . If I try to use a comma

rewrite url. asp.net c# [closed]

↘锁芯ラ 提交于 2019-11-29 13:06:39
how to rewrite url string. in asp.net with c#.net. ASP.NET supports URL rewriting via System.Web.Routing , it is not just for ASP.NET MVC. See How to: Use Routing with Web Forms on MSDN. To have URL ~/foo handled by page ~/example/foo.aspx register the route in global.asax.cs void Application_Start(object sender, EventArgs e) { Route r = new Route("{Parameter}", new ExampleRouteHandler()); Routes.Add(r); } And the route handler might look like this: public class ExampleRouteHandler : IRouteHandler { public IHttpHandler GetHttpHandler(RequestContext requestContext) { string page =

ASP.NET routing: Literal sub-segment between tokens, and route values with a character from the literal sub-segment

我们两清 提交于 2019-11-29 09:26:18
The reason I'm asking is because IIS protects certain ASP.NET folders, like Bin, App_Data, App_Code, etc. Even if the URL does not map to an actual file system folder IIS rejects a URL with a path segment equal to one of the mentioned names. This means I cannot have a route like this: {controller}/{action}/{id} ... where id can be any string e.g. Catalog/Product/Bin So, instead of disabling this security measure I'm willing to change the route, using a suffix before the id, like these: {controller}/{action}_{id} // e.g. Catalog/Product_Bin {controller}/{action}/_{id} // e.g. Catalog/Product/

ASP.NET routing on IIS 6

匆匆过客 提交于 2019-11-29 06:13:53
问题 I have created a basic site using ASP.NET routing according to Mike Ormond's example "Using ASP.NET routing Independent of MVC". This works fine on my local machine running the built-in web server. However, when I deploy it to my server (Windows Server 2003, IIS 6, ASP.NET 3.5 SP1) it just shows a 404 error. I have read somewhere that I am meant to set up wildcard routing. How can I do this? What other configuration changes needs to be done to make it work on my server? 回答1: You will find

ASP.NET route to mvc or api by subdomain

烈酒焚心 提交于 2019-11-29 05:22:41
Our application have 2 domains (www | api).mydomain.com How can I route requests to api.mydomain.com to api controllers and www to mvc controllers? Thank you I solved my problem using constraints. This site gave me the clue: http://stephenwalther.com/archive/2008/08/07/asp-net-mvc-tip-30-create-custom-route-constraints.aspx And here is my implementation: public class SubdomainRouteConstraint : IRouteConstraint { private readonly string _subdomain; public SubdomainRouteConstraint(string subdomain) { _subdomain = subdomain; } public bool Match(HttpContextBase httpContext, Route route, string

rewrite url. asp.net c# [closed]

狂风中的少年 提交于 2019-11-28 06:57:22
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . how to rewrite url string. in asp.net with c#.net. 回答1: ASP.NET supports URL rewriting via System.Web.Routing, it is not just for ASP.NET MVC. See How to: Use Routing with Web Forms on MSDN. To have URL ~/foo

ASP.NET MVC 5 - (HTTP Error 404.0 - Not Found) with long non-existing URL

a 夏天 提交于 2019-11-28 06:05:45
I created a new project in Microsoft Visual Studio Express 2013 for Web. It is an ASP.NET MVC 5 - .NET Framework 4.5 project. I wanted to handle (The resource cannot be found): I did handle it using the code below. This code will work if I do something like (/Home/kddiede/ddiij) or (/djdied/djie/djs), this will result in showing my custom Error page. However, when I try to do something like (/Home/kddiede/ddiij/dfd/sdfds/dsf/dsfds/fd), or any long non-existing URL, It will show me this: Code from: http://www.codeproject.com/Articles/635324/Another-set-of-ASP-NET-MVC-4-tips Tip 16: Customizing