MVC Bundling with HTTPS IE7 - asp.net-mvc

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.

Related

Rails 4.1 analytics and site verification

My site is in Rails 4.1.7 and is hosted in Ninefold.
I want to verify and add Google Analytics to it.
I tried uploading html file in public folder, no go.
I tried creating controller and route, didn't work.
I tried a couple of solutions that were supposed to do a workaround in turbolinks and added the analytics script to the footer. Didn't work
Any ideas?
I must add that in the first two solutions, the html / action were accessible through the browser call but not through external links (when you try to verify, it gives you a link in webmasters tools), which has led me to believe it's a csrf situation, where rails blocks incoming connections from other websites.
UPDATE: I have this solution live, analytics shows me some data but site verification still does not work.
UPDATE 2: Ok, i solved it. The problem was that i had stated the domain as domain.com in Ninefold and forgot about it, and then i was trying to verify www.domain.com in Google. Solved by adding the extra domain and verifying both of them.

AngularJs Routing | don't change 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.

Cleanly deploying PJAX or Turbolinks application

If I have an application that uses PJAX or Turbolinks then I am seeing a problem when new code is deployed to the server - say Heroku. The issue is that users who are accessing the application will continue to use the Javascript from the previous version of the application (since it is already loaded into the browser), but will get the HTML pages from the new version. Sometimes the new HTML code assumes the new Javascript is loaded so things don't work properly.
Have others noticed this problem? What do you do about it? It seems like this would be a common problem for single-page Javascript applications (like those based on Backbone and Ember) too. Meteor at least seamlessly upgrades the code in the client, as a way to deal with this problem.
https://github.com/rails/turbolinks/#asset-change-detection looks like the answer. In your script tags, put data-turbolinks-track. Then I assume what happens is that when turbolinks loads a page, it looks for that script tag, and if the URL has changed (it will change automatically if you use the asset pipeline) then it reloads the whole page for you.
taking pivotaltracker as an example, they check for the client connection and force the user to reload their clients if a new version arrived.
as long as you don't provide backwards compatibility within your app, there is nothing else you can do.
If you're using Pjax, you can add
<meta http-equiv="x-pjax-version" content="v123">
to your header. You can use a server defined value for the content attribute, and then before you deploy, just make sure that value is updated. Once it's deployed, subsequent Pjax requests will see this header has been updated, cancel it's Ajax request, and pull down a full page reload.
For Turbolinks 5, you can add data-turbolinks-track="reload" to your script and stylesheet links in the header. Turbolinks will watch these files for changes on each request. Then upon deployment, just like Pjax, it will request a full page reload.
Classic Turbolinks just requires the attribute data-turbolinks-track instead.
You can read more and see other functions on Pjax's GitHub page: https://github.com/defunkt/jquery-pjax or Turbolinks: https://github.com/turbolinks/turbolinks.
For Turbolinks Classic: https://github.com/turbolinks/turbolinks-classic

Why is meta refresh redirect no longer working and how can I fix it?

Thanks in advance for any help you can provide!
I have a website built in Ruby on Rails. My site has a webpage, located at example.com/communityboard, that you can use to enter a separate Community area (an off-the-shelf bulletin board called bbPress.)
I want users who type in the URL example.com/community to be redirected to example.com/communityboard . It used to work this way, but for some reason, the redirect no longer works in any browser but IE.
We accomplished this redirect by placing an index.html file in the /community folder where bbPress had been installed. The entire code for the index.html file reads
<meta http-equiv="refresh" content="0;url=http://example.com/communityboard">
Back when we built the site, I was told that a meta refresh redirect using an index.html file was the best option. The redirect had to address ONLY a single page (http://example.com/community) and not all of the sublevels of the community bb (which lives at http://example.com/community/index.php). Otherwise, the community bb and all of its sublevels would be redirected.
So... my questions:
Why is the meta refresh redirect not working anymore?
How can I fix it?
Thanks again for any help you can offer!
If it's only working in IE, it's possible there's a script or parsing issue that's breaking other browsers. I would run the HTML through a validator like http://validator.w3.org/.
Meta-refresh is a legacy practice that is now discouraged -- the wikipedia entry contains more info and links to alternative solutions: http://en.wikipedia.org/wiki/Meta_refresh.
Here's what happened according to my developer. I don't fully understand the explanation, so I'm not sure I can answer follow-up questions! "With the old mongrel cluster, Apache would recognize "/community" as a directory, silently forward to "/community/", which would then pick up the forwarding index.html file. With Phusion Passenger," which I guess we're using now, "Apache sends the request directly to Passenger if "/community" is not a regular file, and Passenger was returning the 404 error. As a fix, we've disabled passenger in the community folder, which fixes the problem."

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