Why are my Script Bundles only working on Server - asp.net-mvc-4

I have deployed my app to my IIS server. The javascript/css seem to work when I browse the webpage from the IIS server (although some of the css seems to not be loading as well). However, when I go to another machine and view the webpage from a client, none of the Javascript seems to be enabled. The links to the scripts are there, and when I type their path into the browser, I am able to retrieve the file (so it's not a permissions issue or a path issue). Yes the browser I am viewing the page from has javascript enabled (it's my dev machine where everything works if I'm working from visual studio).
Can anyone help me figure out what is happening here? Everything works fine in my dev machine.
Edit
Ok I have tried everything I can find on the interwebs. I have tried adding the 'bundle' module, removing then adding (as below), I have tried with and without 'runAllManagedModulesForAllRequests', I have tried enableing and disabling the
<compilation debug="false" targetFramework="4.5" />
Nothing seems to work.
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
<!-- any other modules you want to run in MVC e.g. FormsAuthentication, Roles etc. -->
</modules>
I just don't understand why IIS7 would be doing something different when you browse the website locally on the server and another thing when you browse the site on different machine?
Edit 2
Even more baffling. I figured there might be something wrong with bundling (some assembly not loaded correctly who knows) so to test the theory, I commented out all the bundling code on my layout and replaced it with hard coded links to the styles/javascript. Again, it works in development, it works when previewing on the server, but when you go to a client machine, none of the javascript seems to work!!! I've installed it on two different IIS servers now... still same problem!
Edit 3
Unbelievable. It looks like the problem is... drum roll. IE10. I am using integrated authentication so I was only using IE. Until I realised that chrome can prompt/pass credentials as well. So I opened the site from Chrome and no problem! I compared the html from my local version on my dev machine to the html coming from the server, and other than the fact that the URLs have an extra element in the path (the site is deployed to a virtual directory) the html is identical. So for whatever reason, IE has decided that it will not run javascript from my IIS server, but it will from every other website on the internet. I even used fiddler to double check that all of the css/javascript was being fetched and received (they are, even checked the temporary files folder after a clean sweep to see if the css/js was downloaded). So, as usual, IE is a piece of crap causing nothing but headache and misery. Now to figure out how to fix this (my organisation is 80% IE).

So for anyone out there who might run into the same issue and has to work with IE I solved the problem by adding this to my _layout.cshtml:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
What this does is instructs IE to use the latest available rendering engine to process the html (in other words don't try to be smart and guess what my html is built for). So it essentially tells the versions of IE that have 'compatibility mode' to not use it.
For me this works fine because our organization is small and we are usually within one version of the latest release of IE. If the latest version causes issues, I can easy fix and deploy with no harm done. However, this IS NOT optimal for a general purpose website or organization with high numbers of users on a variety of IE browsers.

I came across this problem too.
I found was that Internet Explorer was set to "high" when browsing the internet when using our corporate network. Once I added my site to the trusted sites zone, everything worked.
You can check if your site in the Trusted Sites zone, but going to Internet Options -> Security -> Sites

Related

JDeveloper deployment "Page can't be displayed" error

For development, I'm using the integrated weblogic feature in JDeveloper. So far, this has worked fine. I was recently put onto a different project, however, and when I try to deploy it, I'm having trouble. Here are the steps I take:
Run->Debug Server Instance (IntegratedWeblogicServer)
In the Projects, I right-click on Web Content->index.html and select Debug.
According to the log, the applicatoin deploys successfully with the target URL of http://localhost:7101/Myapp-Myapp-context-root/index.html and it then attempts to open the page.
However, this gets me a "This page can't be displayed" in Internet Explorer. No error messages in JDeveloper's log or IE's console. I realize this doesn't give a lot of information to work with, but it's all I've got right now.
One other thing, and I don't know how relevant this is, but if I attempt to refresh the page or enter it into a different browser, it redirects to https://localhost:7102/Myapp-Myapp-context-root/index.html
I figured it out. It switching to a secure port was related, as the finalized product is supposed to do that. Development requires the security-constraint fields in the web.xml to be commented out.

How can I determine the Reason IE is going into Compatibility View Mode and prevent it from happening?

Okay, here are the facts regarding our problem:
The web site we are working on is designed to use modern HTML5 features. This includes indexedDb.
We are using the following HTML right at the top of each page:
<!DOCTYPE html><html><head><meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
All our users are using the same version of IE11.
We have 200+ active users who use the site, and for most of them, everything works just fine. The browser stays in "Edge" mode.
So far though, 3 of those users' browsers started opening the pages on the site in Compatibility View Mode instead of the default Edge mode. It was working for them fine previously.
If any other user goes to any page that those 3 users went to, they open fine (in Edge mode).
I created a super-simple diagnostic page devoid of CSS, HTML5 features, etc., when the users who are having the problems go to this page, it STILL going into compatibility view mode! It seems once the damage has been done, the browser wants to go into compatibility view mode for that domain regardless of the page content!
We've tried deleting Browsing History in the user's browser including cookies and website data... it does not fix the problem.
Restarting the PC does not work.
We do not have enough security to access any registry settings or directories where the browser stores its files.
So for starters, the question is, what steps can we take to figure out WHY their browsers when into compatibility mode in the first place. The only things I'm finding are vague error messages in the F12 console about using some feature or other improperly. No info about what feature or what error it caused.
And then, if that can be resolved, for users already in this mess, is there any viable steps we can take to get them so they see the site in Edge mode once again.
I'll be grateful for any help I can get on this. I am really stumped on this one!

Aurelia with VS2015: Modifications to view not visible to the client

I'm using Aurelia with Visual Studio 2015. I started with the project as an empty ASP.NET 4.6 project. But when I change my view, I don't the see the new html elements on the browser side. It seems like the browser is caching it and not getting the new view from my server.
From the F12 tools window, I see no HTTP traffic going to the server except the fetch to get data from the Web Api service.
What server configuration is necessary to make my code updates visible on the browser?
I disable caching ... In Chrome, F12 and then click the Network tab. Check the "Disable cache" checkbox. Ctrl-F5 to clear and refresh. After that, the network tab shows request going out with HTTP Status 200 response and I see the changes. [BUT WHAT IF: I don't want to use the developer tools to control the caching. I just want the module loader to always get the file from the server?]
By default, IIS allows browsers to cache static content such as html, and image files. To avoid that, you need to disable static content cache in the web config file as follows:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache"/>
</staticContent>
</system.webServer>
</configuration>
UPDATE:
You also need to clear the browser cache because the html files are already cached and therefore the browser will not request them to the server. Once the browser cache is cleared and the configuration in place, you will not experience the problem anymore.

Problems asp.net 2.0 in IE10

We have a website developed in vs2005 with framework 2.0.
The website works fine in all browsers unless IE10. The response.redirect doesn´t work and some buttons throws javascript errors.
If a force the explorer mode to IE10 compatibility view works fine, but we don´t want to tell all our users to force manually.
Anyone have the same problem?
Thanks a lot and best regards
I solved a similar problem by inserting the App_Browsers map into the root map, containing a browser file BrowserFile.browser with the code:
<browser refID="Default">
<capabilities>
<!-- To avoid wrong detections of e.g. IE10 -->
<capability name="ecmascriptversion" value="3.0" />
</capabilities>
</browser>
Try it:
Open your website in IE10
Tools > Compatibility View Settings >
Click in Add to your domain website >
Close
Reload your website.
It´s worked for me.
There is a bug in the browser definition files that shipped with .NET 2.0 and .NET 4, namely that they contain definitions for a certain range of browser versions. But the versions for some browsers (like IE 10) aren't within those ranges any more. Therefore, ASP.NET sees them as unknown browsers and defaults to a down-level definition, which has certain inconveniences, like that it does not support features like JavaScript, CSS etc.
Try the fix given in the below link. Worked fine for me.
http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx

Moving from IIS6 to IIS7.5 - Custom Handlers

I am moving a site from IIS6 on one server to IIS7.5 on another.
This site was not writen by me, and from what I can tell, they use custom handlers to get around the AJAX limitations of the day.
I copied the code from the old server to the new (pre-compieled) and everything works except the "AJAX" stuff. There are several calls in the code to ashx files. These calls return .js files. On the old server this works great. Does not work on the new server.
In the web.config file I found the following lines:
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
For some reason this is not working in IIS7.5
Any suggestions are welcome.
Thank you!
I suspect this could be down to the configuration of the application pool managed pipeline mode. You can easily confirm this by changing the Managed Pipeline Mode for the application pool the site runs under to Classic. If this works and you want to continue to run in Integrated mode then you will need to add a handlers section to the web.config. This is different from the httpHandlers information you noted above.
The new handlers section should be in the system.webServer section. I'm sorry I do not know the exact setting for the item you note but you will need to include the preCondition="integratedMode" if you wish to run in integrated mode.