Angular2 how to use replaceUrl:false in the app.routing.ts - angular2-routing

I defined a component for an error page, and would like to make it so the URL does not change any time I navigate to the error page. Can I use replaceUrl: false in the route definitions? If not how can I do this?
Edit:
I found this question that is exactly what I am looking for - the answer this links to looks interesting but I don't understand what NavigationError is, or what the code should look like that initiates this.
Angular2 How to display error page while keeping route
Seems like allowing replaceUrl:false in the route config would be simpler if possible.

Related

how to avoid HTTP status code 404 on nuxt error.vue

Using Nuxt, we need to be able to render pseudo-routes, like this:
https://server.com/non-existent-route
Where "non-existent-route" is a dynamic path.
Normally, this would render error.vue. This is fine, as we've subverting the use of this page to render what we want. But... we just discovered that Nuxt is sending a 404 anyway! This only happens when the page is first loaded in a fresh tab, for some reason. This is very bad.
So, we need a way to avoid HTTP status 404 in some cases.
We found this:
https://medium.com/finn-no/hacking-nuxts-404-logic-for-maximum-awesome-and-easy-proxying-e4efaeb03d66
which is actually not as helpful as we had hoped it would be, as it simply provides a way to proxy another URL, sending us back to the same problem.
We suspect there might be some middleware solution to this problem... but have not been able to come up with it.
Turns out the answer was right here all long:
https://nuxtjs.org/guide/routing#dynamic-nested-routes
Rather disappointing that nobody suggested this extremely simple solution.

How can I store data to use it any where in my element

I am face to a problem and I can not find a solution!!! may not enougn experience with CakePHP :o)
I created a setting pages (Controller+Model+view)
On admin_edit action, I created a form to enter the parameter of the web site, as the site of name (to be display on the layout), the status (online or not), the id of the home page, ect.
I may be did it wrong but until I can not use variable on all element.
I tried Configure::write or Set('val',$val) but with both of them, I could not use it eighter on the layout or on a controller.
As I spent almost a day, I would like tp know if someone can provide me an exemple to create an array (or something else) to be able to use it's value, either on a layout, a controller, a view, an element or a compnent, or a Helper. But the main need, would be on a Controller, the layout and the view.
may thank for any tuto or exemples
P.
Your question indicates that you need to get a basic understanding of how CakePHP works.
To understand how a request is made, take a look at the picture in the section "CakePHP request cycle" in this link:
http://book.cakephp.org/2.0/en/cakephp-overview/understanding-model-view-controller.html
As you can see, Controller asks Model for data, then sets that data to the View. The View can never send data back to the Controller - that would be a new request.
To understand the use of layouts,elements and how to set variables in views, see the cookbooks description of Views:
http://book.cakephp.org/2.0/en/views.html
And of course follow the blog tutorial is a good thing to get a grip of the basic concepts.

URL of page that required login in Symfony2

I've got a Symfony2 site where I would like to display extra information on the Login page depending on the URL that the user is trying to access. I'm using "use_forward". Is there a way to see the URL in the login form's controller?
I guess I could set up multiple firewalls pointing at different login pages, but there could be quite a lot of them, so I'd rather avoid having to do this.
If you want something "proper" then look at the answers to this question.
OR
If you want to do it quick and dirty you can use:
$this->container->get('request')->server->get('PHP_SELF');
Whick will yield something like /project_name/web/app_dev.php/controller_name/ and you can work with that string, but take into account that it will change depending on the enviroment you are working on. The Request class documentation will be your ally in this, ie:
$this->container->get('request')->getBasePath()
Will give you /project_name/web/
You can try to look for this URL in some places:
$url = $request->get('_referer');
If it is empty, then you could try to check the headers
$url = $request->headers->get('Referer');

Using Selenium : How to modify or inject into HTTP Post Data Request Header?

Please note this question is related to Selenium.
Before a HTML form submit i.e., selenium.click("//button[#type='submit']");
I want to inject a name value pair at native level in the HTTP Post back to the Server e.g.
Change HTTP Post from:
POSTDATA=register=true&accountType=customer
To:
POSTDATA=register=true&accountType=customer&mynewfield=true
Working with Selenium commands its not obvious how to intercept and modify what is posted back to the server.
Any ideas of how to achieve desired result in Selenium or something that can be called from Selenium? Kindly appreciated NJ
In theory you could use javascript or jQuery to alter the page. For example, using jQuery you could add a hidden form element with a default value or pre-set value that will then be passed upon form submission. (if i understand your question right - emulating TamperData?)

Issue with IHttpHandler and relative URLs

I've developed a IHttpHandler class and I've configured it as verb="*" path="*", so I'm handling all the request with it in an attempt of create my own REST implementation for a test web site that generates the html dynamically.
So, when a request for a .css file arrives, I've to do something like context.Response.WriteFile(Server.MapPath(url)) ... same for pictures and so on, I have to response everything myself.
My main issue, is when I put relative URLs in the anchors; for example, I have main page with a link like this Go to Page 1 , and in Page 1 I have another link Go to Page 2. Page 1 and 2 are supposed to be at the same level (http://host/page1 and http://host/page2, but when I click in Go to Page 2, I got this url in the handler: ~/page1/~/page2 ... what is a pain, because I have to do an url = url.SubString(url.LastIndexOf('~')) for clean it, although I feel that there is nothing wrong and this behavior is totally normal.
Right now, I can cope with it, but I think that in the future this is gonna bring me some headache. I've tried to set all the links with absolute URLs using the information of context.Request.Url, but it's also a pain :D, so I'd like to know if there is a nicer way to do these kind of things.
Don't hesitate in giving me pretty obvious responses because I'm pretty new in web development and probably I'm skipping something basic about URLs, Http and so on.
Thanks in advance and kind regards.
First of all I would take a look at the output HTML delivered to the browser and specifically the links that you are describing.
You say that the link is Go to Page 2 but according to your result I would guess it is more like Go to Page 2.
You can confirm this by placing a brakepoint in the handler and when it triggers with "~/page1/~/page2" look in the address bar of your browser and it should say something like "http://www.example.com/page1/~/page2"
You should first look at the code generating the link. If it is generated from some kind of function call, make sure you get the web address and not the script address.
In any case these kind of links that switch between first level pages should all start with a "/" indicating that their location is relative to the root of your website rather than relative to the current shown page.

Resources