Asp.Net MVC4: Jquery Bundle is Blank - asp.net

I have a simple project that contains these two bundles:
bundles.Add(new ScriptBundle("~/Scripts/jquery").Include(
"~/Scripts/jquery/jquery-{version}.js",
"~/Scripts/jquery/jquery-ui-{version}.js",
"~/Scripts/jquery/jquery.unobtrusive*",
"~/Scripts/jquery/jquery.validate*"));
bundles.Add(new StyleBundle("~/Styles/jquery").Include(
"~/Styles/jquery/jquery-ui-1.8.22.custom.css"));
This seems to work fine locally (debug mode so they aren't bundled); however, once I published the files to my file system, and move them out to the server, it is no longer functioning correctly:
I can see that both (bundled) file references are on the page; however, if you look at what the server actually sent, both files are blank.
What would cause the server to send blank files for these two bundles?

Doing some more research, I could see for those two files the server was actually sending a 301 redirect response to a different generated file, and these generated files were the blank ones I was receiving.
Since this server has several applications and sites running on it (some mvc), I thought this might be some weird bug with the bundling system, and renamed my bundles from 'jquery' to just 'jq', since other applications are probably using those names, and that did solve the problem

Related

Laravel app serving resources that do not exist?

I am in the process of adding a Content Security Policy for a laravel application. While downloading external css and font styles to the local assets I have run into some odd template behavior.
I wanted to test that the paths to the newly downloaded libraries were correct, but when I change the name of files I downloaded and refresh, even with the browser cache disabled, it is still referencing the old location successfully. If you try to access the file in the old location directly by file path it fails (because it no longer exists).
Even more strangely, if I pull the code down to another computer and run it (I have not added the new libraries to git yet), the page still seems to think it correctly loaded that resource.
I tried clearing the following directories:
storage/framework/cache
storage/framework/sessions
storage/framework/views
and running the code again - on multiple computers, and it still reports that it is loading these files that are no longer there?
Does Laravel or commonly used front end frameworks with it store compiled templates somewhere else? I am completely perplexed...

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?

Updating .aspx pages

I've inherited an ASP.NET project that uses a single Default.aspx file in the public_html root to do most of the work.
The changes I'm making are minor, but I can't seem to get them to stick. If I edit the Default.aspx file, the server will still serve the old version. Creating a new .aspx file will initially compile it and run it, but then it's stuck in its "original request" form.
I thought .aspx files were subject to "dynamic recompilation" if they were changed, but this isn't triggered in my case. I've tried updating the Web.config file but is has no effect.
I'm not using Visual Studio for this, yet. I'd like to be able to just edit and update the files, if possible (the changes are very minor and I don't have ready access to a Windows machine). The only access I have to the server is through FTP.
Seems the issue was with my host, who aggressively cache stuff. I have to do a "restart" from inside their control panel to have the changes reflected.
The host is Loopia.se, in case anyone else is using them. Use "Omstart av ASP.NET-applikationer" from inside the Customer Zone to restart things.
(Yes, I do feel kind of silly now)
If the site has previously been 'published' in visual studio as pre-compiled and not-updatable, then changing the aspx files will result in no change:
http://msdn.microsoft.com/en-us/library/1y1404zt(v=vs.80).aspx
In this case everything will have been pre-compiled into DLL's, and the aspx pages are just there as hooks for the .net runtime.

Custom VirtualPathProvider unable to serve URLs ending with a directory

As part of a CMS, I have created a custom VirtualPathProvider which is designed to serve a single file in place of an actual file structure. I have it set up such that if a file actually exists on the server, that file will be served. If the file does not exist, the virtual content stored for that address will be served instead. This is similar to the concept of serving a website from files stored in a database, though in this case the content is stored in XML files on the server.
This setup works perfectly when a request is made to a specific page. For example, if I ask for "www.mysite.com/foobar.aspx", the content that is stored for "foobar.aspx" will be served. Further, if I ask for "www.mysite.com/subdir/foobar.aspx", the appropriate content will also be served.
The problem is this: If I ask for something like "www.mysite.com/foobar", things begin to fall apart. If the directory exists on disk (and doesn't have a configured default page in IIS, such as index.aspx), I will get a "Directory Listing Denied" error. If the directory does not exist, I'll simply get a 404 - Resource Not Found.
I've tried several things, and so far nothing I've done has made a bit of difference. It seems as though IIS is simply noting the nonexistence of a directory (or default file in an existing directory) and serving up its own error code, without ever asking my application what to do with the request. If it ever did get to the application, I would be able to solve the problem, but as it stands, I'm quite lost. Does anyone know if there is some setting in IIS that is causing this?
I've looked for every resource I can find on the subject, and am coming up empty. I know this should be possible, because I have read tutorials on serving content from both databases and ZIP files. HELP!
p.s., I am running IIS6 and .NET 3.5
IIS will only pass a request to the ASP.NET process if it is configured to do so for the particular extension. The default is aspx, ascx, etc. In other words, if you request a .html file, ASP.NET will never see that HTTP request. Likewise for empty extension.
To change this behavior, add a wildcard mapping to the ASP.NET process. Load IIS Manager, go to the Properties for your web site and look at the Home Directory tab. Click on "Configuration" and there you will see the extension-to-applicaiton mappings.

Can you precompile and merge part of an ASP.NET website and then continue development?

A big part of the web site is precompiled and merged, since it's almost never going to change. The precompiled bits can be replaced in case of updates to the original. I want to continue development of new pages, but when I browse to a new page I get the following error:
The file '/Website/Test/Default.aspx'
has not been pre-compiled, and cannot
be requested.
Is there any way around this?
Edit:
If I remove the precompileApp.config file I get the contents of the marker files when I browse them:
This is a marker file generated by the precompilation tool, and should not be deleted!
Have you looked at the precompile with updatable UI option? This compiles all the source code and resources into a DLL but allows you to continue making changes to your .aspx pages after deployment.
Another option could be to precompile the website in place on the server instead of precompiling it then deploying it to the webserver.
Both options are addressed in this MSDN article:
http://msdn.microsoft.com/en-us/library/bb398860.aspx

Resources