asp.net-routing

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

微笑、不失礼 提交于 2019-11-28 03:10: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:

Api controller declaring more than one Get statement

自闭症网瘾萝莉.ら 提交于 2019-11-27 17:42:06
Using the new Api Controller in MVC4, and I've found a problem. If I have the following methods: public IEnumberable<string> GetAll() public IEnumberable<string> GetSpecific(int i) This will work. However, if I want to retrieve some different data of a different type, it defaults to the GetAll method, even though the $.getJSON is set to the GetAllIntegers method: public IEnumberable<int> GetAllIntergers() (bad naming conventions) Is it possible for me to be able to do this? Can I only have a single GetAll method in the Web API controller? I think it's easier to visualise what I'm trying to

How to redirect to a dynamic login URL in ASP.NET MVC

杀马特。学长 韩版系。学妹 提交于 2019-11-27 16:47:06
I'm creating a multi-tenancy web site which hosts pages for clients. The first segment of the URL will be a string which identifies the client, defined in Global.asax using the following URL routing scheme: "{client}/{controller}/{action}/{id}" This works fine, with URLs such as /foo/Home/Index. However, when using the [Authorize] attribute, I want to redirect to a login page which also uses the same mapping scheme. So if the client is foo, the login page would be /foo/Account/Login instead of the fixed /Account/Login redirect defined in web.config. MVC uses an HttpUnauthorizedResult to return

Can ASP.NET Routing be used to create “clean” URLs for .ashx (IHttpHander) handlers?

余生长醉 提交于 2019-11-27 03:45:33
I have some REST services using plain old IHttpHandler s. I'd like to generate cleaner URLs, so that I don't have the .ashx in the path. Is there a way to use ASP.NET routing to create routes that map to ashx handlers? I've seen these types of routes previously: // Route to an aspx page RouteTable.Routes.MapPageRoute("route-name", "some/path/{arg}", "~/Pages/SomePage.aspx"); // Route for a WCF service RouteTable.Routes.Add(new ServiceRoute("Services/SomeService", new WebServiceHostFactory(), typeof(SomeService))); Trying to use RouteTable.Routes.MapPageRoute() generates an error (that the

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

耗尽温柔 提交于 2019-11-27 01:11:30
问题 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

Api controller declaring more than one Get statement

蓝咒 提交于 2019-11-26 19:08:58
问题 Using the new Api Controller in MVC4, and I've found a problem. If I have the following methods: public IEnumberable<string> GetAll() public IEnumberable<string> GetSpecific(int i) This will work. However, if I want to retrieve some different data of a different type, it defaults to the GetAll method, even though the $.getJSON is set to the GetAllIntegers method: public IEnumberable<int> GetAllIntergers() (bad naming conventions) Is it possible for me to be able to do this? Can I only have a

ASP.NET MVC, Url Routing: Maximum Path (URL) Length

筅森魡賤 提交于 2019-11-26 17:15:36
The Scenario I have an application where we took the good old query string URL structure: ?x=1&y=2&z=3&a=4&b=5&c=6 and changed it into a path structure: /x/1/y/2/z/3/a/4/b/5/c/6 We're using ASP.NET MVC and (naturally) ASP.NET routing. The Problem The problem is that our parameters are dynamic, and there is (theoretically) no limit to the amount of parameters that we need to accommodate for. This is all fine until we got hit by the following train: HTTP Error 400.0 - Bad Request ASP.NET detected invalid characters in the URL. IIS would throw this error when our URL got past a certain length.

Can ASP.NET Routing be used to create “clean” URLs for .ashx (IHttpHander) handlers?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 10:46:14
问题 I have some REST services using plain old IHttpHandler s. I\'d like to generate cleaner URLs, so that I don\'t have the .ashx in the path. Is there a way to use ASP.NET routing to create routes that map to ashx handlers? I\'ve seen these types of routes previously: // Route to an aspx page RouteTable.Routes.MapPageRoute(\"route-name\", \"some/path/{arg}\", \"~/Pages/SomePage.aspx\"); // Route for a WCF service RouteTable.Routes.Add(new ServiceRoute(\"Services/SomeService\", new

ASP.NET MVC, Url Routing: Maximum Path (URL) Length

Deadly 提交于 2019-11-26 04:38:48
问题 The Scenario I have an application where we took the good old query string URL structure: ?x=1&y=2&z=3&a=4&b=5&c=6 and changed it into a path structure: /x/1/y/2/z/3/a/4/b/5/c/6 We\'re using ASP.NET MVC and (naturally) ASP.NET routing. The Problem The problem is that our parameters are dynamic, and there is (theoretically) no limit to the amount of parameters that we need to accommodate for. This is all fine until we got hit by the following train: HTTP Error 400.0 - Bad Request ASP.NET