url-routing

Yii2 routing when using CamelCase action names

柔情痞子 提交于 2019-11-28 10:59:32
If you have say the following controller structure <?php namespace app\controllers; use Yii; use yii\web\Controller; /** * Test controller */ class TestController extends Controller { public function actionMyaction(){ ... //action logic } public function actionMyAction(){ ... //action logic } } The first route can be accessed using the path example.com/test/myaction The second route per Yii 1.x logic should be accessible from the path example.com/test/myAction in Yii2.x routing is using hyphenated structure and is accessible only from example.com/test/my-action Is there anyway to enable

Web.config: Wildcards in location and authorization

我与影子孤独终老i 提交于 2019-11-28 09:10:42
In my ASP.Net application I'm using URL routing. The url format is somewhat like: http://site/{culture}/project/{id} . To allow users to visit the login and recovery page, I've added the following entries to my web.config: <location path="en-GB/login"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location> <location path="nl-NL/login"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location> <location path="login"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location> Is there a form of

ASP.Net: HTTP 400 Bad Request error when trying to process http://localhost:5957/http://yahoo.com

旧街凉风 提交于 2019-11-28 08:30:23
问题 I'm trying to create something similar to the diggbar. I'm using Visual Studio 2010 and Asp Development server. However, I can't get the ASP dev server to handle the request because it contains "http:" in the path. I've tried to create an HTTPModule to rewrite the URL in the BeginRequest , but the event handler doesn't get called when the url is http://localhost:5957/http://yahoo.com. The event handler does get called if the url is http://localhost:5957/http/yahoo.com To summarize: http:/

Discovering Generic Controllers in ASP.NET Core

强颜欢笑 提交于 2019-11-28 08:22:21
I am trying to create a generic controller like this: [Route("api/[controller]")] public class OrdersController<T> : Controller where T : IOrder { [HttpPost("{orderType}")] public async Task<IActionResult> Create( [FromBody] Order<T> order) { //.... } } I intend for the {orderType} URI segment variable to control the generic type of the controller. I'm experimenting with both a custom IControllerFactory and IControllerActivator , but nothing is working. Every time I try to send a request, I get a 404 response. The code for my custom controller factory (and activator) is never executed.

$state transition after rejected promise Angular ui-router

筅森魡賤 提交于 2019-11-28 08:20:11
I'm using Angular ui-router and have a resolve function set up for one of my states, before the controller is initialized. I retrieve some data, loop through and match it up the URL stateParam, and if a match is found, resolve the promise to the controller and return that object in the promise. That's all working well. However, if a match isn't found I simply want to redirect to a different state by rejecting the promise and running $state.go('state'); Simply this: deferred.reject(); $state.go('state',{params: 'param'}); But this doesn't seem to do anything. The controller just hangs, and I

ASP MVC Redirect without changing URL(routing)

本小妞迷上赌 提交于 2019-11-28 07:54:31
问题 Goal: I want to be able to type URL: www.mysite.com/NewYork OR www.mysite.com/name-of-business Depending on the string I want to route to different actions without changing the URL. So far I have: public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute( "UrlRouter", // Route name "{query}", // URL with parameters new { controller = "Routing", action = "TestRouting" } // Parameter defaults ); } In the controller I have: public ActionResult TestRouting(string query) { if

Using Url.RouteUrl() with Route Names in an Area

半城伤御伤魂 提交于 2019-11-28 07:02:38
问题 As a side note, I understand the whole ambiguous controller names problem and have used namespacing to get my routes working, so I don't think that is an issue here. So far I have my project level controllers and then a User Area with the following registration: public class UserAreaRegistration : AreaRegistration { public override string AreaName { get { return "User"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "UserHome", "User/{id}", new {

Angular2 router: how to correctly load children modules with their own routing rules

孤街浪徒 提交于 2019-11-28 06:46:26
here is my Angular2 app structure: Here is part of my code. The following is the main module of the Angular2 app, that imports its routing rules and a child module ( EdgeModule ) and uses some components related to some pages. app.module.ts @NgModule({ declarations: [ AppComponent, PageNotFoundComponent, LoginComponent ], imports: [ ... appRouting, EdgeModule ], providers: [ appRoutingProviders, LoginService ], bootstrap: [AppComponent] }) export class AppModule { } Here is the routing rules for the main module. It have paths to login page and page not found. app.routing.ts const appRoutes:

turn URL route into funciton arguments php mvc

泄露秘密 提交于 2019-11-28 05:30:44
问题 I'm writing a custom MVC framework for a PHP project and everything is great until it comes to getting arguments from the URL route. I'm stuck on passing parts of the URL route into a function argument dynamically. I already have a method which is just to implode the route and use the array for the function arguments but I would really like to know how to do it like in CodeIgnitor or CakePHP. Here's what i want to have done. The site url would be... url: http://yoursite.com/profile/view/35

Serving multiple content types

北慕城南 提交于 2019-11-28 05:25:04
问题 I'm creating a website and API with Express, I want to serve multiple content types (JSON, XML, HTML) on the same paths. In Express is there a better way to write the following: // Serve JSON requests app.get('/items/', function(req, res, next){ if(!req.accepts('application/json')){ return next(); } res.end([1,2,3,4,5]); }); // Serve XML requests app.get('/items/', function(req, res, next){ if(!req.accepts('application/xml')){ return next(); } res.end('<items><item>1</item><item>2</item><item