AngularJs Routing | don't change URL - url

I am developing an App that uses the AngularJs Router.
So my URLs look like that:
appName/viewOrders
My problem is, when I refresh the browser with F5 I get an 404 Error. (Because there isn't a folder or even file named viewOrders)
I can't redirect it via a config file because I am not able to use one in the environment where I am developing (An Sharepoint 2013 App).
So I came to this idea:
When I click the navigation, the Url doesn't change and stays at
/appName
But the view does it.
How can I achieve it? Have I to use the ui-router?

If you have restricted access and are unable to use the answer #tommyd456 (which it sounds like that may be the case), another option is to omit the url completely using stateProvider (ui-router).
Angular ui-router: Can you change state without changing URL?

Not sure if you've solved this issue but here's a potential solution anyway...
You're using HTML5 mode so you need server-side rewrite as explained here: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode
However, it sounds like you've got restricted access to a server so why stop HTML5 mode.
Don't hack at it like you're suggesting - that could get nasty.

Related

Umbraco URL issue with Vorto

I am using vorto plugin in my Umbraco 7 application to achieve the multilingual capability.
I mentioned the URL in hostname as 'localhost/clientname/en'.
Whenever I open login page the URL which is getting form is 'http://localhost/clientname/en/login'.
This is the structure of vorto URL writing.
But can I achieve it like 'http://localhost/clientname/login/en' ???
I want language names at the end of the URL, not in between.
Is it possible ?
Please help....i am badly stuck in my project task !
It sounds like you need a custom URL provider, setting the domain to 'localhost/clientname/en' will mean that the URLs will always get added AFTER the language part as the host is always the first part of the URL.
Have a look at this article on URL providers and content finders: https://24days.in/umbraco-cms/2014/urlprovider-and-contentfinder/ it's quite old, but it should still work. That should give you an idea of how to make it work. Basically you want the URL provider to append the language to the end of the URL, and the content finder to strip the language from the end and then find the actual content. You can also then set the language of the current thread in the content finder so that Vorto and Umbraco are using the correct language based on the URL.

Creating a chrome:// page for my Firefox add-on

I am building a simple Firefox add-on using the Add-on SDK, and I need it to display some information when first ran.
I don't want to rely on an external URL for this, so I figured that my best option is to use the chrome:// scheme.
I have two questions
How to create said page?
Is it possible to pass a value to it (something along the lines of welcome.html?key=abc)?
You need to register a content or resource url scheme in chrome.manifest. You will be able to use window.location object there as usual.

MVC Bundling with HTTPS IE7

I have successfully implemented MVC bundling for my MVC application. There is one problem with the run time which runs under HTTPS.
I am sure there is a problem because when I switch the debug field to false the user gets the warning message "This page contains secure and nonsecure items. Do you wish to proceed?
I know that I can turn this prompt off using the security setting in IE. I would like to know if there is something I can do to the application so that bundled scripts and styles come through the secure pipe.
If you use the Scripts.Render helper to include the bundle it will use the same HTTP scheme as the one used to request the main page. So if the main request was done over HTTPS then this helper will generate a <script> element using HTTPS. You could use the Net tab of FireBug to see which resources are served through HTTP and HTTPS and be able to isolate the problem.
Thank you for this suggestion. I figured out that the problem was coming from modernizr-1.7.js
The strange thing was that this problem only occurs when modernizr is bundled. I removed modernizr because we don't really need it.

Possible to have ampersands ("&") in URL BEFORE the query string?

My client is determined to have a page at /nfm&t so I made a directory named nfm&t with an index.html (to test) and that URL is still throwing a 404. So apparently it's not that easy.
Any ideas? Or is there a way to just redirect nfm&t to nfmt, so that the URL at least resolves?
This is a Windows server, by the way, which throws a wrench into how I'm used to doing redirects.
Turning on AllowRestrictedChars and enabling VersionCompatibility should do it.
Why would a Windows Server throw a wrench into how you do redirects? If you are using IIS 7, you can use URL Rewrite Module. It is built into IIS. If you are using IIS 6, there is ISAPI Rewrite, which is an external module. Both use the same syntax as mod_rewrite for Apache.
Do you have a /nfm directory? If you don't, try making one. Either way, put in a Default.aspx file and have it spit back at you the exact path it's trying to access. Chances are, when you have this here, it will go to example.com/nfm/Default.aspx and let you run something from there.
If you do get to that directory, then try redirection to example.com/nfm%26t and see if it works. If this still doesn't help it, then you're SOL
I tried this on my Snow Leopard ( OSX 10.6.2 ) workstation with Apache and it works. That is from Firefox 3.6. Looks like a Windows thing you are struggling with. Honestly I didn't think that would work without encoding but you never know until you try.
alt text http://www.vertigrated.com/images/so_screenshot.png
Or is there a way to just redirect
nfm&t to nfmt, so that the URL at
least resolves?
Sure. Make a general url handler and/or an error handler. When it encounters a url, if that url is equal to /nfm&t, then under the hood rewrite the context to whatever page you actually really want to return. Is this a good idea? Probably not. But it will work. Keith's answer suggests two ways to grab the url and do stuff, though you could also do this via a global asax file (being careful to execute an aspx page when you hit an error so it actually gets hit) if you're using .Net.

ASP .Net MVC - Images not being shown in published build

I am developing an ASP .Net MVC application and on my dev machine, the application runs as expected and, more importantly, the images mentioned in the CSS file are displaying correctly too.
However, when I publish this application to a testing server, the web app runs fine, but the images are not shown.
If I modify the URL in IE when testing the output from the test server, the image is returned, meaning that the file is there but it just won't appear within the view page when using the site normally.
I have tried alternative servers too, but the result is the same.
To confirm, here's a line from the CSS page referencing the image...
background-image: url('/Content/Images/Logo/myLogo.jpg');
Any suggestions?
Cheers
Brett
The URLs are not correct, likely due to the fact that you are publishing in a subfolder and so they are no longer at the root of the server. I usually use Url.Content( "~/Content/Images/..." ) to build the url instead of hard-coding it. That way it will take into account the routes when building the path.
Example:
<img src='<%= Url.Content( "~/Content/Images/banner.jpg" ) %>' alt="Banner" />
I had the same issue, but I found the reason why it was forcing authentication on the Contents folder.
When a user is not logged in yet, they are classified as Anonymous Authentication. In IIS7 (which is what I am using, guessing it is the same in IIS6) you need to open the authentication window in features view. Then edit the Anonymous Authentication, to use your application pool identity, or the default one, just make sure that user has permissions to read in that folder.
That fixed it for me, hope it works for you.
Possible relative paths are wrong...Possible that they are wrong for CSS file itself. You can use FireBug to see if CSS loaded correctly, then you can examine image request, often in such situations you will see red(error) items. This could help to localize problem.

Resources