What does the * in the line:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
mean?
Does it mean "match everything that looks like: {resource}.axd/1/2/3/4/5 or something like that?
The wildcard provides a catch-all route. It allows, as you assume, any number of paramters after the wildcard parameter:
AnyResource.axd/any/number/of/parameters/will/be/valid
It's also useful when creating a CMS and you want process the url yourself rather than using static routing parameters. Example:
"{*slug}"
You could create a lookup table in your database and retrieve the specific page for the provided slug.
Related
I have an api that dynamically pulls a post. localhost/api/post/[postId]
I want to extend functionality to retrieve the comments of the post at the URL localhost/api/post/[postId]/comments
What is the correct way to structure this in Next.js? I am thinking to create a dynamic route and check if the query equals comment? localhost/api/post/[postId]/[comment]
The following file structure should work:
/pages/api/post/[postId]/index.js //Route: /api/post/1
/pages/api/post/[postId]/comments.js //Route: /api/post/1/comments
Besides that, just to follow good practices, I would recommend that you rename "post" to "posts", like that:
/pages/api/posts/[postId]/comments.js
Is there a way to pass a specific UI language to the registration page? This is coming from the website and I want it to be the defaut option.
you can send the culture with these headers
c=...
uic=...
https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore/AspNetCore/Localization/AbpLocalizationHeaderRequestCultureProvider.cs#L12
and for MVC use culture parameter like below
/register?culture=tr
must be the first parameter of the query string
and last option; you can always override AbpUserRequestCultureProvider
https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore/AspNetCore/Localization/AbpUserRequestCultureProvider.cs
UPDATE:
According to the implementation it accepts query string parameters as culture like below
?culture=es-MX&ui-culture=es-MX
See https://github.com/aspnetboilerplate/aspnetboilerplate/issues/2103
If you look at the request headers sent by the browser, it includes "Accept-Language". It can look something like this:
en-US,en;q=0.9,es-419;q=0.8,es;q=0.7
Generally, the preference runs in descending order, so here, the browser is saying it prefers U.S. english before anything else. More here about what the q values mean: What is q=0.5 in Accept* HTTP headers?
You can access this value through in the controller.
Request.Headers["Accept-Language"]
I've been trying to pull the parameters passed into a page so I can post it back in Context.
So far,
ViewBag.Message = string.Format("{0}::{1}::{2}",
RouteData.Values["controller"],
RouteData.Values["actions"],
RouteData.Values["id"]);
works with anything simple like "66" or "tt" but anything more complex like "?name=blargh?viewId=66" and it fails.
I've tried a bunch of different ways to see if I could strike gold but nothing seems to work so does anybody have any idea what I'm missing/doing wrong/should be doing instead?
" but anything more complex like "?name=blargh?viewId=66" and it fails.
This doesn't seem to be routing information but query string which you should retrieve from the Request.QueryString bag.
If the {id} parameter is part of your route (as the default routes {controller}/{action}/{id}) I hope you realize that this id cannot be anything you like just because there are rules for an url. For example it cannot contain ? because this symbol has an entirely different meaning in an url - it represents the query string separator.
I started using Laravel 3 last week, and then found the new 4 release and I'm trying to convert now.
I have a dozen+ routes that I want to deliver to a specific controller method. i.e., "/api/v1/owners/3/dogs/1 or /api/v1/owners/3" to run "myresourcecontroller#processRequest"
In Laravel 3 I was able to use this: (note * wildcard)
Route::any('api/v1/owners*', 'owners#processRequest'); // Process tags resource endpoints
I found this example from the documentation but it gives me an error. I get a NotFoundHttpException.
//[Pattern Based Filters](http://laravel.com/docs/routing#route-filters)
Route::filter('admin', function()
{
//
});
Route::when('admin/*', 'admin');
Not sure what I'm doing wrong? Is there another way to do this?
I don't want to use the Laravel 4 restful controllers, cause they don't seem to conform to complete restful design. i.e., no verbs in the url.
I have all of my processing written, I just need to be able to route to it.
I need to be able to create new records by POST /api/v1/owners or /api/v1/owners/3/dogs
I cannot use /api/v1/owners/create.
I'm trying to avoid having to write a route for every endpoint, i.e.,
Route::any('api/v1/owners/{owner_id}', 'owners#processRequest');
Route::any('api/v1/owners/{owner_id}/dogs/{dog_id}', 'owners#processRequest');
Thank you for any help
You should make use of resourceful controllers as they're a great asset when building an API. The endpoints you described can be achieved using resource controllers and nested resource controllers.
Route::resource('owners', 'OwnersController');
Route::resource('owners.dogs', 'OwnersDogsController');
Would allow you to create an owner with POST localhost/owners and create a dog on an owner with POST localhost/owners/3/dogs.
You can then wrap these routes in a route group to get the api/v1 prefix.
Route::group(['prefix' => 'api/v1'], function()
{
Route::resource('owners', 'OwnersController');
Route::resource('owners.dogs', 'OwnersDogsController');
});
Haven't used Laravel myself, but try any('api/v1/owners/*', (note slash before asterisk) as in the example.
Hi ive just hear about an error in cakephp that allows sql inyection;
https://twitter.com/cakephp/status/328610604778651649
I was trying to test my site using sqlmap, but i cant find how to specify the params.
The url i am testing is;
http://127.0.0.1/categories/index/page:1/sort:id/direction:asc
And the parameters i want to sqlmap inyect are in the url (page:,sort:,direction:)
I have try to run;
python sqlmap.py -u "http://127.0.0.1/categories/index/page:1/sort:id/direction:asc"
But nothing...
Any clue? Thanks!
In CakePHP there are passed arguments, named parameters, and querystring parameters.
Passed arguments look like .../index/arg are accessed with $this->request->pass[0], where '0' is the array index. Named parameters look like .../index/key:value and are accessed with $this->request->named['key']. Querystring parameters look like ̀.../index?key=valueand are accessed with$this->request->query['key']`.
Your URL uses named parameters so it should look like this (without the question mark):
http://127.0.0.1/categories/index/page:1/sort:id/direction:asc
Edit:
Since CakePHP uses mod_rewrite, you have to specify the parameters as explained in the sqlmap wiki.