Angular 2 Routing configuration in liberty Websphere server - angular2-routing

My angular 2 app runs fine on my local node server. However when the dist/prod contents are deployed to a server (to be precise websphere liberty server) The url just works fine for once. When I try to reload it, it gives me File not found exception. Also the deep routes for e.g http://localhost:5555/myapp/route1/somefeature/extra doesn't work and throws the same exception.
Just to confirm:
I am using proper basehref (for e.g '/myproduct/')
The server.xml contains proper contextpath ('/myproduct/')
Thus the url http://someserver:8080/myproduct/myapp runs fine but when refreshed or deep routes are hit, it throws file not found exception
I have gone through this post Angular2 routing / deep linking not working with Apache 404 and need the similar kind of settings in my server.xml (for liberty websphere server)
Since I do not want to go back to include old implementation of hash(#) urls, Any help in this regard is much appreciated.

Did you try in web.xml?
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>

Related

Manually added WebResource.axd - Any security implications?

I added WebResource.axd (empty file) manually in production environment (IIS7 and Windows Server 2008) after chrome and firefox was giving error 404 for WebResource.axd. And now it is working fine, even with parameters. I am not sure why ASP.NET generating this script in final render result (no problem with VS2008), but now it is working. I want to know, is there any security implications other than what normally associated with WebResource.axd as it is in root directory?
Thanks
I also had this issue recently, after a code change WebResource.axd stopped working for my site. Basically, it exposes dynamic resources over http. For a longer explanation visit:
Just where is webresource.axd?
Typically, what happens is that one of the dynamic resources being requested has failed, but the resource name is encrypted. This blog post will help you decrypt the name, use it and the query string of your failing webresource.axd?___ request to figure out where the error is coming from.
Telerik webresource troubleshooting

HTTP handlers not registering correctly under Mono MVC 3

I am at my wit's end. I'm trying to run an ASP.NET MVC 3 website under Mono via FastCGI and the HTTP handler for Cassette won't register correctly. The site is http://www.tychaia.com/.
The strange thing is:
It works fine on my local machine.
It works fine when the site is run under xsp4 on the production machine.
It doesn't work fine when the site is run under fastcgi-mono-server4 on the production machine.
Things I have tried:
Checking the Nginx configuration, making sure it's passing in all the correct FastCGI parameters (it is).
Mono 3.0.7 and 3.0.10. A friend has it working under 3.0.7, but no dice for me.
It is this particular Web.config entry:
<add path="cassette.axd" verb="*" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
(https://github.com/hach-que/Tychaia/blob/master/Tychaia.Website/Web.config#L47)
As far as I can tell, I have two problems that are causing this issue:
MVC's IgnoreRoute is not matching the cassette.axd URL, even though it is clearly specified at https://github.com/hach-que/Tychaia/blob/master/Tychaia.Website/Global.asax.cs#L20 (and it works under plain old XSP4). When I add an explicit IgnoreRoute for the string "cassette.axd" (by doing routes.IgnoreRoute("cassette.axd");), lo-and-behold, it starts passing through to the handler, except:
The server's HTTP handler path matching seems to only do exact matches under FastCGI. Even when I turn off all of the MVC registration in the site, the handler only matches cassette.axd and even then it seems like the handler doesn't have any path information.
When I add further entries like <add path="cassette.axd/*" verb="*" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" /> these also start being handled by the handler, but it doesn't respond as it normally should at that URL; you just get the default as if there were no additional URL parameters (perhaps they are being consumed by the HTTP handler path matching).
The way that FastCGI is currently setup is:
Main Nginx instance which is just a reverse proxy into more Nginx instances (I run multiple sites and I like to keep them isolated). It directs into:
The Nginx instance for http://tychaia.com/, which calls FastCGI over a UNIX socket.
Again, this issue doesn't occur under XSP4, it's only occurring under FastCGI. While I could reverse proxy this to an XSP4 instance, I'm hesitant to do that for performance reasons.
Is there anything else I could be missing here?
EDIT: Here's some URLs that should work. As you can see, they are hitting the StaticFileHandler instead of the Cassette HTTP handler:
http://tychaia.com/cassette.axd/stylesheet/nDvbK5eAxf6miyaRa_J0vl7YdxA=/Content
http://tychaia.com/cassette.axd/script/oz4BBh-gK6gJkhB5S64l3mXseFQ=/Scripts
And you can see that with the IgnoreRoute specified explicitly, the cassette.axd path does map, but only that path:
http://tychaia.com/cassette.axd
It doesn't work if you put a slash at the end of it either:
http://tychaia.com/cassette.axd/
EDIT 2: I have updated the site to just link to the /Content/main.css file so the site appears correctly while this issue gets sorted; if you check the network requests in your browser, you'll see the failed requests to the Cassette bundles.
I have filed a bug on the Mono bug tracker, hopefully to get an answer as to why this is happening:
https://bugzilla.xamarin.com/show_bug.cgi?id=12190
UPDATE: I have found the cause of the issue. Under OpenSUSE, mono and XSP are packaged seperately. Even though I upgraded Mono to 3.0.10, XSP/FastCGI still remained at version 2.10.2.0. When I upgraded the XSP/FastCGI package to 2.11.0.0, the issue disappeared.

Glassfish docroot and unreachable crossdomain

I am trying to access a webservice from Flex. The webserivce is deployed on Glassfish 3.1 application server. Now, Flex needs a "crossdomain.xml" file at the root (top-level) of the server.
Here is the problem: I searched and found that the crossdomain file should be inside the docroot directory (c:\Glassfish3\Glassfish\domains\domain1\docroot). That is exactly the where I put it, and yet I get a 404 when I try to reach it.
I also tried putting it under applications but it didn't work.
What should I do?
Thank you,
Ido
OK, I found the answer, though I'm not sure that this is recommended.
Inside Glassfish admin console, under configurations --> server-config --> Network config --> http-listener-1.
I changed the address from "0.0.0.0" to the actual IP address of the server.
Now It works fine and I am getting access to crossdomain.xml, but as I said, I am not so sure that this action is recommended and won't make other errors.
Thank you.

Tomcat 6 constantly redirecting URL to old one

I've done a lot of searching and not found anything like this, but I might not be using the right terms. My problem is this:
On a Tomcat 6 server, I originally deployed a Spring Webflow app with a context root of fred - to access it people went to myserver.com:8080/fred
The Spring code in that app changed all requests to have /spring after the context root - so the URL above would become myserver.com:8080/fred/spring - and this would bring up the index page.
That was all fine & dandy.
I rewrote the app to use Spring MVC instead, for reasons too boring to mention here, and as part of this removed the code that performed the /spring piece.
I am now trying to deploy it to the same Tomcat instance. It appears to deploy fine (after undeploying the old one).
However when I try to hit myserver.com:8080/fred to get the index page, it redirects to myserver.com:8080/fred/spring, and naturally this fails as that URL is not supported.
I've checked my config within the WAR, and also scanned through the following places in Tomcat:
conf directory
conf/catalina and subdirectories
webapps and subdirectories
work and subdirectories
I can't see anything referring to this /spring url rewrite. It does deploy and work successfully on my local version of Tomcat.
Could anyone offer any suggestions? All help is appreciated.
Sounds like your browser cached the redirect. If your site at myserver.com:8080 used hard redirects (301 Moved Permanently) to send users from /fred to /fred/spring your browser will remember that the next time you access the application. Try emptying the browser cache and trying again.
That would explain why everything is dandy on your local machine

Request Filtering/URL rewriting with IIS7 - not working

I cannot get the URL rewriting module to work on my local PC (vista x86)
i set up a new rule using the 'user friendly url' template.
a picture rather than 1000 words....
(the image contains 3 shots - creation, config and pattern test)
http://www.sk8loc8.com/rewriteIssue.jpg
so now that is setup if i request 'localhost/iisrewriteurl/content/5 i should see my content.aspx page.
nope...
Error Summary
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Detailed Error Information
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL IISRewriteURL/content/5/
Physical Path C:\Users\Guy\Documents\Visual Studio 2008\Projects\IISRewriteURL\IISRewriteURL\content\5\
Logon Method Anonymous
Logon User Anonymous
When i go back into the rule itself and test the patterns that IIS made for me, they do not work..
I have tried adding a wildcard script map under the handler mappings section but this makes no difference.
Has anyone seen this type of behaviour before? Or am i missing something very simple?
If you test the pattern you dont need the Host
I always just create Blank Rules and not had a problem that way since not sure if it matters though. I cannot discover why that rewrite wouldnt work perhaps other rules are blocking it?
Alternatively you may have a look at Helicon Ape product that emulates Apache modules behavior on IIS7. It has simpler syntax and Helicon Ape Manager automatically checks the syntax of the rules you write.

Resources