System.Web.Optimization bundles are empty when running in a virtual directory - asp.net

I'm having problems when deploying my application to a server using a virtual directory in IIS.
I have configured the same files to run under the default website in a virtual directly and also in a new website root running on port 81. Both configurations use their own identical app pools. While the site on port 81 works fine the site running in a virtual directory doesn't load the bundles.
In the page I see links with missing versions in the URL, such as:
<link href="/MyVirtualDir/Content/css/site?v=" rel="stylesheet">
The URL returns a 200 status from the server, but the content is completely empty.
I have looked on SO at questions like this which references this bug ticket but my understanding is that this is when the files being included in the bundle are 'virtual' or not under the physical folder root. Which is not true in my case.
Cheers for any help you can give me. I can't believe that this configuration wouldn't be supported so I must be doing something wrong somewhere!
Update:
I think a ticket describing my problem has been raised on the web optimisations codeplex site here http://aspnetoptimization.codeplex.com/workitem/55 Not that this gets me any further though :(

After comparing with a new project I tracked down the problem:
I was using T4MVC (trying to be clever and not use 'magic strings' in my code). So I was using a link such as
bundles.Add(new ScriptBundle("~/Scripts/all")
.Include("~"+Links.Scripts.Library.jqueryPlugin.jquery_ui_js), ...));
When this runs under a virtual directory it will resolve with the virtual directory name in the path, so it can't find the files.
I hope this helps someone else who runs into the same problem. Also, it looks like T4MVC are looking to improve the use of magic strings in bundles in future releases. See here for a discussion

Related

Symfony2 assests in bundles directory 404 error

After doing some research, I still cannot understand why my assets in the bundles folder return 404 errors when I try to reach them.
I can see the files on the server, but when I try to reach them, symfony returns a 404 error.
For example, I have this file on the server : web/bundles/aluser/images/li-plus.png, but trying to access it with https://my-site.com/bundles/aluser/images/li-plus.png returns a 404 error. But on the other hand I can access files in https://my-site.com/images/li-plus.png for example.
I did the assets install and dump commands, cleared the cache but no results.
Thank you.
Unless you are on a local install it probably has to do with your server not pointing to the web folder. I had that problem on a shared hosting what i did was to make a symlink from server home (www, public_html or whatever) to web and it worked like a charm.
Thank you all for your answers,
they pointed me in the right direction (a problem with the server) :
I did a asset install and dump commands with the root user of the server, all files created were then associated to this root user, and apache wouldn't serve them anymore.
After a chown, everything was working again.
Thanks again :)

MAMP Start Page Only Shows Index

I'm trying to install Wordpress on MAMP using this tutorial. When I start the MAMP server and go to the MAMP startup page, I see this index instead of a GUI. As a result, I can't access the PHPMyAdmin GUI (despite the PHPMyAdmin link) to create a database for Wordpress. Does anyone know what I might be doing wrong? I'm running OSX 10.9.5.
Try that url to access phpmyadmin
http://localhost:8888/phpmyadmin/
This is the directory listing that Apache provides in some cases. When a folder is requested, Apache looks in a folder for a file name matching the DirectoryIndex directive, which are often files such as index.php, index.html, home.htm, and so on. Since none of those exist here, the directory listing is shown.
Basically, something isn't right here with your MAMP install; either this URL is not designed to be accessed by you ever or your installation is incomplete. First, try loading http://localhost:8888 directly and see if that works any better for you. Failing that, I suggest you make a backup of any MAMP related files (databases, web pages, or configuration changes) and reinstall. One possible cause of this is if the MAMP package is not installed to /Applications/
In short, when you're using an all-in-one package like MAMP this shouldn't happen. You say that when you uninstalled and reinstalled that fixed the problem which is what I would have suggested anyway. It seems something went wrong with the installation and that should (and did) fix it.
I add the solution that helped me in the similar situation just in case someone later will face the same problem when after the Wordpress has been installed, a browser just show "Index of/" instead of the required site.
Check the following points:
There is 'index.php' file in the root folder of your project. (web server tries to open exactly this file).
If the file actually is located there, check the configuration of your web server. For example in my case my web server is Apache 2.4. After I added the directive "DirectoryIndex index.php" in the Apache configurations file (thereby saying to the server which file it should open if it received the address of the root folder) my problem was solved.

The changes not updating on server

I have build MVC 5 application which works fine when running via VS. When I publish it to the server first time it also works. Now I have made few correction to my css file and publish whole project again but website still see the old css file. I have removed all files from the server and tried few more times but it is still the same. When I check the css file on the server, the changes are inside the file.
I think it is related to MVC bundling as when I check the source it says that is accessing different file which is not even located on the server:
<link href="/Content/cssmain?v=Ikj7NnMg3q9kTHR7ynWOJDQFGMZl3mtVMi_2EkOJxc41" rel="stylesheet"/>
How can I force VS to minificate my css file again?
I've tried cleaning, rebuilding but no luck
Edit:
My bundle set up look like below and all files are located on the server in Content folder.
bundles.Add(new StyleBundle("~/Content/cssmain").Include(
"~/Content/bootstrap.css",
"~/Content/site.css",
"~/Content/ilightbox.css",
"~/Content/bannerscollection_zoominout.css"));
Many thanks
I think it is related to MVC bundling as when I check the source it says that is accessing different file which is not even located on the server:
CDN location? External Css lib (yours or 3rd party)? unsure what you meant by "not located on server"?
Yup, it does (look like ASP.net Bundling in action) - check your Global.asax, App_Start/BundleConfig or _AppStart and see if the bundle configuration setup point to/reference the "correct" locations for your css (and or script).
Is it just you experiencing getting the old css file loaded? Or anyone who views the site?

Drupal Export of Site Not Working For Subdirectory Levels Beyond Root Directory

I have to move an existing Drupal site from one server to another. I've done so by doing a mysql database export/import and copying over the files to the new server. On the new system, the root page comes up fine but if I try to go to any deeper directory levels I get a 404 Not Found Error.
so drupal.newserver.com -> works fine
but drupal.newserver.com/user -> gives me a 404 and happens,same for all subdirectories
Is there something that I'm missing that is part of a drupal export? Could it be related to the structure of the /sites directory which is under the webserver's docroot?- which has a folder named after the old server (ie drupal.oldserver.com but not drupal.newserver.com? Also, I noticed that there are _htaccess files and .hta files but not .htaccess files in the site files that I've copied over.
Sorry if I'm asking a bleedingly obvious question - I'm very new to Drupal. Thank you!
Check whether the clean url is enabled in your web server. To check try this:
drupal.newserver.com/?q=user.
Just to let anyone who might come across via a google search - I was able to get this to work . It turns out that while mod_rewrite was enabled, what I had to do was to enable the AllowOverride directive for the web directory in httpd.conf to be set to ‘All’. If it’s not set to this, the server won’t respect the .htaccess rules you put into the drupal directory. It’s been a while since I’ve worked with apache config files so it took a while to finally piece it together. The main breakthrough came when I realized that if I turned off clean-urls then the links worked but looked ugly and then was able to research clean_url.

Download existing file from IIS results in File does not exists (404)

I have a full working web site that i ported to a new hosting company.
In some pages i have links to PDF on the server (they do exist!)
On the old server no problem.
On the new one when user clicks on the link : error 404 file does not exist...
Should i look in the web.config ? i don't know where to start
thanks
John
Start from the file read permissions.
You need to read the log files, or the event viewer to see whats really is the problem.
This is probably as simple as the files not being in the exact relative location to the page that they used to be in - e.g. there was a folder /pdfs in the root of the web where all the files were, now they are just in the root folder, and the links were not updated.
You've not said which version of IIS you're using. However for IIS5, this has been answered over at ServerFault -- see https://serverfault.com/questions/79094/serve-pdf-fies-in-iis
It should be similar for IIS6. It's possible your hosting provider may have revoked the MIME type so IIS no longer recognises it.
What you may end up needing to do if your hosting company isn't forthcoming is write a "file provider" page that takes the file to download on the query string (obviously with some sanity checking so folk can't request any old file), then just writes it out, bypassing what IIS would do normally.

Resources